Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use VBScript to determine whether I am running a 32-bit or 64-bit Windows OS?

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
like image 362
Santhosh Avatar asked Aug 27 '10 11:08

Santhosh


People also ask

How do you check if a file is 32bit or 64bit?

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.

How do I run a VBScript in 32-bit mode on a 64-bit machine?

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.

Is VBScript 64-bit?

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.


2 Answers

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

like image 102
Bruno Avatar answered Sep 19 '22 15:09

Bruno


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.

like image 30
Regis Desrosiers Avatar answered Sep 16 '22 15:09

Regis Desrosiers