Run script from cmd

hi guys,

i need to run a .cmd file.

I have this command but the process cmd.exe gets stuck:

Execute-Process -Path "C:\Windows\System32\cmd.exe" -Parameters "-Command & { &`"$dirsupportfiles\Setup.cmd`"; Exit `$LastExitCode }" -Wait

Unfortunately, I need to install software with custom parameters and the installation is only possible with the prompt, so PowerShell only serves me as a bridge.

setup.cmd in turn needs to run a vbscript.

thanks for your support

-Command is not something that CMD.EXE will understand.
CMD.EXE won’t understand ; Exit $LastExitCode` either.

This should work:

Execute-Process -Path "C:\Windows\System32\cmd.exe" -Parameters "$dirsupportfiles\Setup.cmd" -Wait

That said, if you want to remove the need for the CMD all-together, post its contents here and I’ll try to convert it to PS.

I had a :poop: tonne of issues getting parameters to work in PS when I started. There was a utility I used that showed how PowerShell would see the parameters given to it. Maybe you can still find it.

hi,

thanks for your suggestion. i modified some parameters to fit powershell and the rest i loaded via cmd as you suggested.

thanks again for the valuable support

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.