Running an executable from PowerShell does not work with spaces in the path

Posted by John Hartley on Server Fault See other posts from Server Fault or by John Hartley
Published on 2011-11-23T05:34:32Z Indexed on 2011/11/23 9:55 UTC
Read the original article Hit count: 273

Filed under:

From the PowerShell prompt:

\Windows\system32\mspaint.exe

will run Paint. So will

Invoke-Expression -command "\Windows\system32\mspaint.exe"

but if there is a space in the path PowerShell spits the dummy e.g.

Invoke-Expression -command "\install\sub directory\test.bat"

Which complains:

The term '\install\sub' is not recognized as the name of a cmdlet, function, script file, or operable program.

What am I missing?

© Server Fault or respective owner

Related posts about powershell