This is kind of a two in one situation... [:)]

1. Are system variables the same/similar in VBScript/WMI as that of Windows, for example: %WINDIR% and, what they?

2. Is it possible to get/display/output the version number of a file based on the OS Architecture ?

For instance:

On Windows 32-bit installations, filename.exe or filename.dll is located in: C:Windows\System32


On Windows 64-bit installations, filename.exe or filename.dll is located in: C:Windows\SysWOW64

I am using VBScript/WMI as such:

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM CIM_DataFile WHERE Path = '\\Windows\\System32\\' AND FileName = 'filename' AND Extension = 'exe'")

For Each objItem In colItems
WScript.echo objItem.Version

What I need to achieve here is to get the version of this file on either: x86/x64/ia64 from a single script with the use of variables if possible.

As you can imagine, using variables like: %WINDIR% for the Path or in the Path in the above, does not work or am I missign something?

The reason for "variables" is that if by chance Windows is installed to a different drive letter, other than C:, it would use that to then locate the filename.exe and get the version information from it.

This code will need to detect:

- If x86 then get file version from here: X:\Windows\System32\
- ElseIf x64 then get file version from here: X:\Windows\SysWOW64\

Where X: is the %SYSTEMDRIVE% and/or X:\Windows is the %SYSTEMROOT% variables in Windows itself.

Any help would be appreciated.
0 Comments   [ - ] Hide Comments


Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
Answer this question or Comment on this question for clarity


This is what you are searching for:
Answered 08/16/2011 by: Teitan
Senior Purple Belt

Please log in to comment