in

Path issue with passing a command from Autohotkey to PowerShell


Mypath := "C:tempexample1.txt"
Run, powershell -command "get-content -path %Mypath% | Set-Clipboard"

The above works just fine, content is copied to the clipboard by PowerShell but when I do the same thing but with a file that has a space in its file name it fails to run in PowerShell.

Running below

Mypath := "C:tempexample 1.txt"
Run, powershell -command "get-content -path %Mypath% | Set-Clipboard"

I get this error in PowerShell

Get-Content : A positional parameter cannot be found that accepts argument '1.txt'.

I have also tried to use double quotes on each side and use Autohotkeys escape symbol like so:

Mypath = "`"C:tempexample 1.txt`""
Run, powershell -command "get-content -path %Mypath% | Set-Clipboard"

As well as

Mypath = ""C:tempexample 1.txt""
Run, powershell -command "get-content -path %Mypath% | Set-Clipboard"

But on both occasions, PowerShell throws this error;

The string is missing the terminator: ".

What am I doing wrong? any help would be appreciated.



Source: https://stackoverflow.com/questions/70599710/path-issue-with-passing-a-command-from-autohotkey-to-powershell

Use regular expressions to detect date format

How to make subtitles change automatically on youtube?⁣