StevensNet.com

...Because someone's gotta tell the story...

Blogs

To return to the main Blog List, click Full Blog Listing.

Tags

Batch File
Error
SCCM
Technical
Troubleshoot
VBScript
Windows

Running VBScript in x64

Thursday, June 02, 2011 in Technical Articles (Views: 2602)
So, this seems to be quite simple, but without resolution.

Say, you have a vbscript that you have used, tried and tested on the x86 platform. This may be common with x86 calls, such as the SMS/SCCM SDK. You then port this script over to x64, and magically, the script fails to run, most likely with the errror:

Microsoft VBScript runtime error: ActiveX component can't create object: '(Name of Component)'

The answer is that the version of cscript running is meant for x64 only, not for the x86 script that was written. So, how can you get this script to fire off? Well, it's a little bit of an annoyance, but here's how. There is another version of cscript in the \windows\syswow64 directory, which will be able to handle these x86 scripts, and simply by calling cscript from the command prompt, you are probably calling the wrong one (from \windows\system32).

A simple way around this is a very easy batch file to determine which version of cscript to run (of course, feel free to add command line parameters as well):

---------------------------------------------------
@echo off
rem Check to see if the computer has the syswow64 directory
rem and cscript, and assume that it is x64 if it exists
if exist %windir%\syswow64\cscript.exe (
%windir%\syswow64\cscript.exe yourscriptnamehere.vbs
goto END
)
rem Otherwise, let's just run normal cscript
cscript.exe yourscriptnamehere.vbs
:END

----------------------------------------------------

Happy Scripting!

 

Related Blogs You May Be Interested In:


To leave a comment, please log in and/or register.