You are hereGetting Older Code to Run on Windows 7 (Problems with cscript and wscript)

Getting Older Code to Run on Windows 7 (Problems with cscript and wscript)


By steve - Posted on 14 February 2011

So I have a bunch of cscript I've written in vbscript and some of it updates databases.

The database connection is done through ODBC (32-bit) drivers, for example with PostgreSQL.

As I've migrated over to 64-bit on a few systems, I haven't run into problems until I have to start dealing with ODBC not seeing 32-bit drivers. This happens a lot, actually.

Anyway, my 32-bit scripts would choke with an error about not finding my connection or driver, even though I could see it fine in the ODBC manager.

The trick was to understand that I wasn't running 32-bit scripts, I was accidentally running 32-bit scripts with the 64-bit cscript program...

There isn't an easy way to say, "hey, run me 32-bit". You have to start the right cscript or wscript program.

The ones in \windows\system32 are actually 64-bit (yeah, that's why they are in a directory called system32...).

The ones in \windows\SysWOW64 are 32-bit (yeah, that's why they are in a directory called SysWOW64...).

Make sense?

To force your 32-bit script to run in 32-bit, start it by calling the entire path of the program:

 c:\windows\syswow64\cscript yourscript.vbs
 or
 \windows\syswow64\cscript yourscript.wsf

Adjust yourscript.wsf or .vbs to your script's name. Change cscript to wscript if that is what you actually want to run.

If you are a 32-bit script and want to make yourself smarter about where you run, there's a nice example here:

http://blogs.msdn.com/b/joshpoley/archive/2008/09/18/running-32bit-depen...

of how to pull some information out of vbscript and find out whether you are already running 32-bit or 64-bit then spawn the 32-bit version of yourself.

Did this help you? You can help me!


Did you find this information helpful? You can help me back by linking to this page, purchasing from my sponsors, or posting a comment!


+One me on Google:


Follow me on twitter: http://twitter.com/mojocode







Comments



Affiliation Badges