Moving to 64 bit: Running VBScript files in 64 bit mode from PrimalScript 2009

PrimalScript 2009 usually uses CScript.exe to run VBScript files and captures its output and directs it to the IDE’s output windows.

Since PrimalScript 2009 is a 32 bit application the host used is also of the 32 bit variety, residing in the System32 folder of your Windows directory.

If you are working on a 64 bit operating system and you have to use 64 bit COM objects you need to be able to run your scripts in 64 bit mode.

In order to do that you can simply change what specific version of CScript.exe is used by specifying the full path:

VBScript64-1

Go to Tools – Options – Environment – Languages and select VBScript. The default entry for the script engine just states “CScript.exe”. If you change that to C:\Windows\Sysnative\cscript.exe you get PrimalScipt to execute the 64 bit version. The “sysnative” substitute for system32 works on Vista, Windows 7 and Server 2008 operating system flavors.

If you don’t want to change the default behavior and just occasionally execute scripts in 64 bit mode, you can just leave the above mentioned setting alone and add the 64 bit engine to your Tools browser:

VBScript64-2

Right click anywhere in the tools browser and select “Customize…” and add a new tool in a group of your choice and add the settings as shown above. In order to run the current script in 64 bit mode you only have to click on the icon.

All these things work just as well for JScript if that is your language of choice, but don’t try this for PowerShell. PowerShell does not like to get its input and output streams redirected and will just hang if you try to do that. We will talk about 64 bit PowerShell in the next installment.