/build/static/layout/Breadcrumb_cap_w.png

VBScript: Get File Version based on OS Architecture ?

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

and

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
Next


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   [ + ] Show comments

Answers (1)

Posted by: Teitan 12 years ago
Senior Purple Belt
1
This is what you are searching for:
http://msdn.microsoft.com/en-us/library/dy8116cf(v=vs.85).aspx
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ