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
You can query the PROCESSOR_ARCHITECTURE
. A described here, you have to add some extra checks, because the value of PROCESSOR_ARCHITECTURE
will be x86
for any 32-bit process, even if it is running on a 64-bit OS. In that case, the variable PROCESSOR_ARCHITEW6432
will contain the OS bitness. Further details in MSDN.
Dim WshShell
Dim WshProcEnv
Dim system_architecture
Dim process_architecture
Set WshShell = CreateObject("WScript.Shell")
Set WshProcEnv = WshShell.Environment("Process")
process_architecture= WshProcEnv("PROCESSOR_ARCHITECTURE")
If process_architecture = "x86" Then
system_architecture= WshProcEnv("PROCESSOR_ARCHITEW6432")
If system_architecture = "" Then
system_architecture = "x86"
End if
Else
system_architecture = process_architecture
End If
WScript.Echo "Running as a " & process_architecture & " process on a " _
& system_architecture & " system."