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.
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:
Set the execution policy globally with a system or domain policy. However, this route doesn't seem viable for you, since you said you don't have admin privileges on the server in question.
Set the execution policy per-user by manually starting C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe
on the server and running the command Set-ExecutionPolicy RemoteSigned
. This must be done for each user and won't work if the excution policy is locked with a group policy (see above).
Bypass the execution policy on the command line by adding -ExecutionPolicy Bypass
to the PowerShell call in file.bat
:
powershell.exe -ExecutionPolicy Bypass -NoLogo -File file.ps1