batch-filevbscriptcmdsystem32syswow64

VBScript - Open batch file with 32-bit cmd


I have a .hta application and the below code.

By default, the below command opens file.bat in C:\Windows\ syswow64 \cmd.exe

How do I get it to open with C:\Windows\ system32 \cmd.exe?

A workaround would be to open the .hta file with C:\Windows\system32\mshta.exe instead of the syswow64 one, but I would like to see other ideas.

Dim objShell
Set objShell = CreateObject("WScript.Shell")
objShell.Run "file.bat"

Many thanks in advance.


Solution

  • Apparently C:\Windows\system32\cmd.exe actually runs C:\Windows\SysWOW64\cmd.exe when launched from a 32-bit environment.

    Thus, as Bill Stewart and Ilya Kurnosov suggested, you'll have to adjust the execution policy for your 32-bit PowerShell. There are 3 ways to do this: