I'm running a VBScript that may run under x64 Windows. I need to read a registry key from the 32-bit part of the registry. For that I use path HKLM\Software\Wow6432Node\xyz
instead of HKLM\Software\xyz
. How can I check if the script is executed under x64?
By default, on 64-bit Windows operating systems, VBScript files are associated with the 64-bit script hosts. However, Rational ClearQuest COM components are 32 bit.
Changing the registry key on a 64-bit computer from "System32" to "SysWow64" will indeed lead VBScript to run GUI scripts in 32-bit. You are correct that the default registry key points to System32\WScript.exe which is the 64-bit binary.
Even on 64-bit version of Windows you script can execute in 32-bit mode.
You can use following code to determine real bit mode, you script running on:
option explicit
function Determine64BitMode
dim Shell, Is64BitOs
set Shell = CreateObject("WScript.Shell")
on error resume next
Shell.RegRead "HKLM\Software\Microsoft\Windows\CurrentVersion\ProgramFilesDir (x86)"
Is64BitOs = Err.Number = 0
on error goto 0
if Is64BitOs then
Determine64BitMode = InStr(Shell.RegRead("HKLM\Software\Microsoft\Windows\CurrentVersion\ProgramFilesDir"), "(x86)") = 0
else
Determine64BitMode = false
end if
end function
dim ExecutingIn64BitMode
ExecutingIn64BitMode = Determine64BitMode
if ExecutingIn64BitMode then
MsgBox "64 bit"
else
MsgBox "32 bit"
end if
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With