Run a .cmd file through PowerShell
Try invoking cmd /c C:\MyDirectory\MyCommand.cmd
– that should work.
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
.
Go to C:\MyDirectory and try this:
.\MyCommand.cmd