PowerTip: Launch Cmd.exe Commands from PowerShell

Doctor Scripto

Summary: Launch legacy applications from Windows PowerShell.

Hey, Scripting Guy! Question Can I execute an old batch script in Windows PowerShell?

Hey, Scripting Guy! Answer To launch an old command or batch file from within a Windows PowerShell script, launch Cmd.exe with the /C parameter:


Or if it’s a .bat or .cmd file, you can put it directly within the Windows PowerShell script and run it:


Note Your results will be in the $LASTEXITCODE.


Comments are closed. Login to edit/delete your existing comments

Feedback usabilla icon