0

I run this command in PowerShell

Start-Process -FilePath 'C:\Program Files\Typora\Typora.exe' -ArgumentList 'C:\Users\Administrator\Desktop\Hello world.md'

But Typora says

C:\User\Administrator\world.md does not exist

It looks like PowerShell executes

Start-Process -FilePath 'C:\Program Files\Typora\Typora.exe' 
     -ArgumentList 'C:\Users\Administrator\Desktop\Hello' 'world.md'

I want to escape the space but the single-quoted not working...

PowerShell version: 5.1.19041.610

phuclv
  • 37,963
  • 15
  • 156
  • 475
  • 1
    You may try inner double quotes inside the single quotes `-ArgumentList '"C:\Users\Administrator\Desktop\Hello world.md"'` – Olaf Sep 08 '21 at 07:00

2 Answers2

0

PowerShell may not quote strings properly when calling external executables. See

So to fix this you need to pass the literal " to the exe file by escaping it properly

Start-Process -FilePath 'C:\Program Files\Typora\Typora.exe' `
    -ArgumentList '"C:\Users\Administrator\Desktop\Hello world.md"'
phuclv
  • 37,963
  • 15
  • 156
  • 475
-1

Try adding ` to excape spaces in powershell:

Start-Process -FilePath 'C:\Program Files\Typora\Typora.exe' -ArgumentList 'C:\Users\Administrator\Desktop\Hello`world.md' 
Harshit Rastogi
  • 1,996
  • 1
  • 10
  • 19