I have a bunch of batch files I need to call from a 32-bit command line.
I have this code:
$cmd = "C:\Windows\SysWOW64\cmd.exe"
$args="/C"
$pipe = "0 |"
Start-Process $cmd $args
If I only call $cmd it opens the command line window. The title says "C:\windows\syswow64\cmd.exe", but the path in the window says "C:\windows\system32".
How can I force PowerShell to run all the batch files to run in a 32-bit system? Also, how can I use the $pipe since some of the batch files require "press any key to continue"?
I was able to run a 32 bit commandline with the code below.
$CMD = "C:\Windows\SysWOW64\cmd.exe"
$test = 'C:\Update\test folder\test.cmd'
$proc = (Invoke-WmiMethod Win32_Process Create "$cmd /c $test")
However, because the folder name has spaces, the code above doesn't work. If I delete the space in the folder name, everything works.
I tried double quotes, single quotes, $a = $test.tostring() with no success.
How can I fix this?
Start-Processat all? PowerShell can run a batch file if you specify its name.& $Env:SystemRoot\SysWOW64\cmd.exe /c D:\Path\test.batwill run the batch file using the 32-bit copy of cmd.exe. But why do you need to do it?