Tuesday 10 March 2015

Detecting Processors Architecture/OS Version through VBScript - Advance Application Packaging


If you want to find the architecture of the machine, you can grab it from the following registry entry:

"HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE"

If your application is a 32-bit application running on a 64-bit OS the process version of this environment variable will return x86.


Option Explicit
On Error Resume Next

dim filesys,objShell,strProgData, StrOSType

Set filesys = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")
StrOSType = objShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE")

If (StrOSType = "x86") Then

strProgData=objShell.ExpandEnvironmentStrings("%programfiles%")
'To Set variable value to 32 bit

else

strProgData=objShell.ExpandEnvironmentStrings("%programfiles(x86)%")
'To Set variable value to 64 bit

End if



Same way we can check the Operating System version

Option Explicit
On Error Resume Next
Dim intOSVersion,OSVersion
intOSVersion = objShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\CurrentVersion")

If intOSVersion = 6.1 Then


OSVersion = "Windows7"


ElseIf intOSVersion <= 5.2 Then


OSVersion = "WindowsXP"


End If



Thank you for reading.

No comments:

Post a Comment