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

Hot How to escape spacespaces in powershella PowerShell one liner-liner

added 36 characters in body
Source Link
Meir Tolpin
  • 365
  • 3
  • 14

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

powershell -ExecutiibPolicyExecutionPolicy 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 -ExecutiibPolicyExecutionPolicy 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

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

powershell -ExecutiibPolicy 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 -ExecutiibPolicy 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?

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

Source Link
Meir Tolpin
  • 365
  • 3
  • 14

Hot to escape space in powershell one liner

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

powershell -ExecutiibPolicy 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 -ExecutiibPolicy 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?