Run a .cmd file through PowerShell

Invoke-Item will look up the default handler for the file type and tell it to run it.

It's basically the same as double-clicking the file in Explorer, or using start.exe.


Try invoking cmd /c C:\MyDirectory\MyCommand.cmd – that should work.


Go to C:\MyDirectory and try this:

.\MyCommand.cmd