Setting/deleting entries in inifiles in Fixlets

(imported topic written by BenKus)

Hi everybody,

We recently were helping a customer with changing an ini file in a Fixlet and I thought I would share with you all what we found:

There is a nifty ini manipulation tool at: http://home.mnet-online.de/horst.muc/wbat32.htm#inifile that will help out a lot. But BigFix cannot redistribute this file (we asked but they said no) so you will need to download the zip file and place it on your server in the wwwrootbes subfolder of your BES Server directory (or on any other webserver).

Here is how you might use it… Imagine that you wanted to change a file “C:test.ini”… Make a new Fixlet:

Relevance:

exists file “C:\test.ini”

(alternate relevance to check to see if the values set in the action exist or not):

(exists file “C:\test.ini”) AND ((key “NewItem” of section “TestSection” of file “C:\test.ini” != “some relevance3”) OR (key “ItemNeedingChanging” of section “TestSection” of file “C:\test.ini” != “ChangedValue”) OR (exists key “ItemNeedingDeleting” of section “TestSection” of file “C:\test.ini”) OR (exists section “TestSectionToRemove” of file “C:\test.ini”))

Action:

// download the ini tool (assumes it has been put locally on the BES Server in the wwwrootbes folder… change the download link as necessary
prefetch inifile.exe sha1:c55da2e08037b234d58a419c4117f3640898b3c5 size:9216 http://127.0.0.1:52311/download/temp/inifile.exe

// store the file locally as a “utility” so the agent doesn’t need to re-download it every time it runs the application
utility __download\inifile.exe

// Run ini files commands:
// add an item/value (for example, set a relevance expression)
wait __download\inifile.exe “C:\test.ini” TestSection NewItem={“some relevance” & (1+2) as string}
// change a value
wait __download\inifile.exe “C:\test.ini” TestSection ItemNeedingChanging=ChangedValue
// delete an item
wait __download\inifile.exe “C:\test.ini” TestSection ItemNeedingDeleting=
// clear an item
wait __download\inifile.exe “C:\test.ini” TestSection ItemNeedingClearing==
// remove a section
wait __download\inifile.exe “C:\test.ini” TestSectionToRemove /remove

WARNING: I never tested this. Please test yourself and let me know what you find…

Hope that helps someone.

Ben

(imported comment written by labuski91)

hey ben what about reading an entry and storing this in a parameter?

edit: i figured out how to do this in the command shell with writing it to a batch file and then calling that batch file, just wondering if there was a way to plug that directly into a parameter in bigfix.

thanks

jesse

(imported comment written by BenKus)

Where did you want to read an entry from?

Ben

(imported comment written by labuski91)

Ben Kus

Where did you want to read an entry from?

Ben

just a sample ini

they say to use the batch file way which would put the command in a shell as

c:\path\inifile.exe “c:\path\sample.ini”

whatever

name > temp.bat

it would write that to a batch file with a set command in it

i would rather use bigfix to where it could be

c:\path\inifile.exe “c:\path\sample.ini”

whatever

name > {parameter name}

i dont think this is possible but would be cool