How do I run a VBScript in 32-bit mode on a 64-bit machine?
follow http://support.microsoft.com/kb/896456
To start a 32-bit command prompt, follow these steps:
* Click Start, click Run, type %windir%\SysWoW64\cmd.exe, and then click OK.
Then type
cscript vbscriptfile.vbs
WScript.exe
exists in two versions, one in C:\Windows\System32\
and the other in C:\Windows\SysWOW64\
directories. They run respectively in 64 bits and 32 bits (against immediate logic but true).
You may add the following code at the beginning of your script so that it automatically starts again in 32 bits if it detects that it's called in 64 bits.
Note that it transmits the arguments if it calls itself to switch to 64 bits.
' C:\Windows\System32\WScript.exe = WScript.exe
Dim ScriptHost : ScriptHost = Mid(WScript.FullName, InStrRev(WScript.FullName, "\") + 1, Len(WScript.FullName))
Dim oWs : Set oWs = CreateObject("WScript.Shell")
Dim oProcEnv : Set oProcEnv = oWs.Environment("Process")
' Am I running 64-bit version of WScript.exe/Cscript.exe? So, call script again in x86 script host and then exit.
If InStr(LCase(WScript.FullName), LCase(oProcEnv("windir") & "\System32\")) And oProcEnv("PROCESSOR_ARCHITECTURE") = "AMD64" Then
' rebuild arguments
If Not WScript.Arguments.Count = 0 Then
Dim sArg, Arg
sArg = ""
For Each Arg In Wscript.Arguments
sArg = sArg & " " & """" & Arg & """"
Next
End If
Dim sCmd : sCmd = """" & oProcEnv("windir") & "\SysWOW64\" & ScriptHost & """" & " """ & WScript.ScriptFullName & """" & sArg
'WScript.Echo "Call " & sCmd
oWs.Run sCmd
WScript.Quit
End If