How to Run 32-bit vs 64-bit VBScript

To run a .vbs VBScript explicitly as either a 32-bit or 64-bit process on a 64-bit Windows system, you need to specify which version of the Windows Script Host (wscript or cscript) to use. By default, the script runs using the version of the Windows Script Host that matches the bitness of the environment in which it is invoked (32-bit or 64-bit).

Running a VBScript as a 32-bit Process

To ensure that the VBScript runs as a 32-bit process on a 64-bit machine, use the 32-bit version of “cscript” or “wscript” located in the “SysWow64” folder.

Example Command:

C:\Windows\SysWOW64\cscript.exe "C:\path\to\your\script.vbs"

or

C:\Windows\SysWOW64\wscript.exe "C:\path\to\your\script.vbs"
  • “SysWOW64”: This folder contains the 32-bit versions of system executables, including “cscript.exe” and “wscript.exe”.
  • “cscript.exe”: Runs the script in a console window.
  • “wscript.exe”: Runs the script with a windowed interface (useful if the script uses message boxes).

Running a VBScript as a 64-bit Process

To ensure that the VBScript runs as a 64-bit process, use the 64-bit version of “cscript” or “wscript” located in the “System32” folder (this folder contains the 64-bit versions on a 64-bit system).

Example Command:

C:\Windows\System32\cscript.exe "C:\path\to\your\script.vbs"

or

C:\Windows\System32\wscript.exe "C:\path\to\your\script.vbs"
  • “System32”: Despite the name, this folder contains the 64-bit versions of executables on 64-bit Windows systems.

Summary:

  • Use “C:\Windows\SysWOW64\cscript.exe” or “wscript.exe” to run the VBScript in 32-bit mode.
  • Use “C:\Windows\System32\cscript.exe” or “wscript.exe” to run the VBScript in 64-bit mode.

Additional Tips:

  • To make this easier, you can create shortcuts or batch files to run your scripts with the desired bitness, specifying the appropriate “cscript.exe” or “wscript.exe” version.
  • If you are uncertain about the bitness, you can include a line in your VBScript to output the process architecture:
    If InStr(WScript.FullName, "SysWOW64") > 0 Then
    WScript.Echo "Running in 32-bit mode"
    Else
    WScript.Echo "Running in 64-bit mode"
    End If
    

This code snippet will show a message box or console output indicating whether the script is running in 32-bit or 64-bit mode.

Tags :