How do i detect the bitness (32-bit vs. 64-bit) of the Windows OS in VBScript?
I tried this approach but it doesn't work; I guess the (x86) is causing some problem which checking for the folder..
Is there any other alternative?
progFiles="c:\program files" & "(" & "x86" & ")"
set fileSys=CreateObject("Scripting.FileSystemObject")
If fileSys.FolderExists(progFiles) Then
WScript.Echo "Folder Exists"
End If
Open the Task Manager by simultaneously pressing the Ctrl + Shift + Esc keys on your keyboard. Then, click on the Processes tab. In the Processes tab, you see the list of processes that are running at the moment. If a program is 32-bit, near its name you should see the text: *32.
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.
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.
Came up against this same problem at work the other day. Stumbled on this genius piece of vbscript and thought it was too good not to share.
Bits = GetObject("winmgmts:root\cimv2:Win32_Processor='cpu0'").AddressWidth
Source: http://csi-windows.com/toolkit/csi-getosbits
Determining if the CPU is 32-bit or 64-bit is easy but the question asked is how to determine if the OS is 32-bit or 64-bit. When a 64-bit Windows is running, the ProgramW6432 environment variable is defined.
This:
CreateObject("WScript.Shell").Environment("PROCESS")("ProgramW6432") = ""
will return true for a 32-bit OS and false for a 64-bit OS and will work for all version of Windows including very old ones.
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