Reputation: 457
The below example does not execute as expected in Powershell:
Path := """C:\Temp\Test 1.svg"""
Run, C:\Program Files\PowerShell\7-preview\pwsh.exe -NoProfile -NoExit -Command Set-MetaData -Path %Path% -Notes "Hello" ,,
It will instead create a new file in Temp
folder called Test
But if the Path being provided by the Path
variable does not have any spaces in it, it runs as expected:
Path := """C:\Temp\Test1.svg"""
Run, C:\Program Files\PowerShell\7-preview\pwsh.exe -NoProfile -NoExit -Command Set-MetaData -Path %Path% -Notes "Hello" ,,
I've tried all sorts of things such as expression syntax of -Path "Path"" -Notes "Hello"
I did not get positive results. Expression syntax always throws me of because of the double quotes , so am not sure if am doing it right.
Upvotes: 0
Views: 359
Reputation: 6489
You're not escaping quotes enough.
You get into a real escape hell here and you actually seem to need quintuple quotes ("""""test test"""""
) around the argument passed into pwsh.exe.
So in AHK you'd want
path := """""""""test test"""""""""
run, % "pwsh.exe -NoProfile -NoExit -Command echo " path
(Tested simply with the echo command because I don't have whatever Set-MetaData
is)
To avoid this headache, you can use single quotes:
path := "'test test'"
run, % "pwsh.exe -NoProfile -NoExit -Command echo " path
Upvotes: 2