Skip to main content
3 of 3
edited tags; edited title
mklement0
  • 452.5k
  • 68
  • 728
  • 988

How to escape spaces in a PowerShell one-liner

I want to run an exe with params using powershell one line, like this -

powershell -ExecutionPolicy Unrestricted "Start-Process -Path program.exe -ArgumentList somefile.txt, Run" 

And it works, but when I am trying to insert full path with spaces it's crashing

powershell -ExecutionPolicy Unrestricted "Start-Process -Path program.exe -ArgumentList "C:\Program Files\somefile.txt", "Run" " 

I tried to use single quote or escape with ` but it's not helping

Maybe someone know what I do wrong?

P.s. running from inside cmd.exe

Meir Tolpin
  • 365
  • 3
  • 14