Newbie dilemma: Handling Program Files (x86)!

(imported topic written by SystemAdmin)

Hey, everyone- I’m new to writing relevance/action script (LANDesk shop converting to BigFix), and I am bashing my head against the wall trying to figure out how to deal with Program Files (x86)!

I would love to slap the microsoft engineer who thought that was a good idea.

Basically, I have an application that has no standard installer (Secunia CSI). It has to be placed in a location and executed with a flag to register it as a service.

Unfortunately, we have a mix of Win 7 and XP systems. So this package needs to work for both.

Relevance: How can I evaluate the presence/version of this executable?

Action: How can I-

  1. Target the correct one,

  2. Execute a command on it

  3. Delete the exe

  4. Replace it with a new one

  5. Run a command on the new one

I’m the kind of person who needs to see an example, then build on that. The documentation is pretty unfriendly.

Thanks!

(imported comment written by SystemAdmin)

Hello MD.

For the relevance the easiest way may just be to say something like this. There are more succinct ways of doing it with “it” causes but this will work as well. Just more verbose:

//determine arch

q: architecture of operating system

A: x86_64

T: 0.038 ms

I: singular string

q: if (architecture of operating system = “x86_64”) then “program files (x86)” else “program files”

A: program files (x86)

T: 0.055 ms

I: singular string

//build the path to the file using the if statement above

q: “C:” & (if (architecture of operating system = “x86_64”) then “program files (x86)” else “program files”) & “\path_to_file.exe”

A: C:\program files (x86)\path_to_file.exe

T: 0.072 ms

I: singular string

//Check for the existance of the file

q: exists file (“C:” & (if (architecture of operating system = “x86_64”) then “program files (x86)” else “program files”) & “\freerip\freerip3.exe”)

A: True

T: 0.174 ms

I: singular boolean

//finally check if A. the file does not exist OR B. If the file does exist and is less than a certain version.

q: not exists file (“C:” & (if (architecture of operating system = “x86_64”) then “program files (x86)” else “program files”) & “\freerip\freerip3.exe”) OR (exists file (“C:” & (if (architecture of operating system = “x86_64”) then “program files (x86)” else “program files”) & “\freerip\freerip3.exe”) whose (version of it <= “4”))

A: True

T: 0.324 ms

I: singular boolean

Action:

In action you can use {} for relevance substitution. To execute:

wait “{“C:” & (if (architecture of operating system = “x86_64”) then “program files (x86)” else “program files”) & “\path_to_file.exe”}”

same thing for delete:

delete “{“C:” & (if (architecture of operating system = “x86_64”) then “program files (x86)” else “program files”) & “\path_to_file.exe”}”

To replace it you can use “move” or “copy” after you delete the original. For instance:

Move “source file” “destination file”

Same as above for executing a command on the new one:

wait “command_to_run”

Beyond this I would highly recommend the 2 day custom content course for a crash course on the major forms of relevance as well as how best to use the resources.

(imported comment written by SystemAdmin)

Beautiful! This is a perfect example. Thank you so much!

(imported comment written by SystemAdmin)

This is a common issue (Program Files) and we have a few special commands to handle other directories that move by wow64 settings, but that one isn’t yet in any released version of the platform.

The others as of the 8.2 release, just so they are all known, are below. Using a 64 bit path from the client will make the client disable the wow64 redirector as it uses the folder. These are highly recommended to use rather than hardcoding any string paths.

Relevance Standard Result looked at from an explorer view (can change based on your system)

windows folder C:\Windows

system folder C:\Windows\SysWOW64

system x32 folder C:\Windows\SysWOW64

system x64 folder C:\Windows\System32

native system folder C:\Windows\System32

system wow64 folder C:\Windows\SysWOW64

Look for updates to this as well in future releases

(imported comment written by SystemAdmin)

My apologies, native system folder isn’t available in 8.2