Help reading ini file

(imported topic written by SystemAdmin)

I am trying to read a line from an ini file. I can identify that the key and section exists, but i need the value after the key “DeviceName”. A sample is shown below. So my result in this example would be “CSBLPT2”. I want to have this as a custom property that I can display in the console when viewing all computers.

Telnet

; Internal J Walk emulator, Telnet connection

CcsId=500

DynamicTransformation=1

GraphicalAccessServices=1

Emulator=Seagull5250

EmulatorConnect=TcpIp

EmulatorSwapEnter=0

EmulatorSystem=0.0.0.0

HidePanels=1

LicenseSystem=

TextAssist=1

WideScreen=1

EmulatorSystemPort=23

DeviceNameSequence=00

DeviceNameSequenceIndicator=Numeric

DeviceName=CSBLPT2

(imported comment written by SystemAdmin)

ok i found through the debugger this:

Q: key “DeviceName” of section “Telnet” of file “C:\Users\Public\SEAGULL\J Walk Windows Client\4.1038.1.500\production\jwalk.ini”

A: CSBLPT2

T: 1.458 ms

So I get the answer i am looking for, and i added this to a new managed property and it works on Win7. How would I modify the relevance to also look in C:\Documents and Settings\All Users\SEAGULL\J Walk Windows Client\4.1038.1.500\production\jwalk.ini for my WinXP? Also, if the file does not exist can the output be “N/A”?

(imported comment written by SystemAdmin)

Easiest way might be through some nested if/then/else statements:

//First start with the if/then/else

q: if () then () else ()

E: This expression could not be parsed.

Now create the if and then portion to check if it is Win7 and the file exists

q: if (name of operating system as lowercase contains “win7” and exists file “C:\Users\Public\SEAGULL\J Walk Windows Client\4.1038.1.500\production\jwalk.ini” ) then (key “DeviceName” of section “Telnet” of file “C:\Users\Public\SEAGULL\J Walk Windows Client\4.1038.1.500\production\jwalk.ini”) else (“b”)

A: b

T: 0.050 ms

I: singular string

//Create a nested if/then/else to check if it is xp and the file exists

q: if (name of operating system as lowercase contains “win7” and exists file “C:\Users\Public\SEAGULL\J Walk Windows Client\4.1038.1.500\production\jwalk.ini” ) then (key “DeviceName” of section “Telnet” of file “C:\Users\Public\SEAGULL\J Walk Windows Client\4.1038.1.500\production\jwalk.ini”) else (if () then () else ())

E: This expression could not be parsed.

//put it all together

q: if (name of operating system as lowercase contains “win7” and exists file “C:\Users\Public\SEAGULL\J Walk Windows Client\4.1038.1.500\production\jwalk.ini” ) then (key “DeviceName” of section “Telnet” of file “C:\Users\Public\SEAGULL\J Walk Windows Client\4.1038.1.500\production\jwalk.ini”) else (if (name of operating system as lowercase contains “xp” and exists file “C:\Users\Public\SEAGULL\J Walk Windows Client\4.1038.1.500\production\jwalk.ini”) then (key “DeviceName” of section “Telnet” of file “C:\Documents and Settings\All Users\SEAGULL\J Walk Windows Client\4.1038.1.500\production\jwalk.ini”) else (“N/A”))

A: N/A

T: 0.071 ms

I: singular string

The statement could be trimmed down with some clever “it” clauses, but this should work.

(imported comment written by SystemAdmin)

awesome…it’s the nested part I am still strugling with. Just now doing a POC with BigFix and having this show in our display is just cool. Will help a lot.

Thanks so much!!!