Beej126 / SingleInstanceAccumulator

Useful for multi-file shell context menu actions
10 stars 2 forks source link

Cannot get SingleInstanceAccumulator to pass in a proper array to Powershell 7. Powershell 5 works, however. #9

Closed futuremotiondev closed 11 months ago

futuremotiondev commented 11 months ago

I have been using the -f switch and reading the temp file to get things working with Powershell 7:

"C:\BIN\SingleInstanceAccumulator" -w -t:115 -f "-c:pwsh -noprofile -noexit -Command \"& 'D:\Dev\Powershell\VSYSWrappers\VSYSImage-CropSVG.ps1' -FileList $files \"" "%1"

It works and speed really isn't as big of a problem as I thought it would be. However today I thought I would try to get SingleInstanceAccumulator to pass filenames directly to powershell using -q.

To my surprise and after a little hacking, I got it to work in Powershell 5. This is the registry command I used:

"%bin%\SingleInstanceAccumulator" -q:' "-c:powershell -noexit "C:\BIN\test.ps1" -filesArray $files" "%1"

powershell_JnwpLWk2Aj

However when I reuse the same command for Powershell 7, things break.

Here's the first command I tried:

"%bin%\SingleInstanceAccumulator" -q:' "-c:pwsh -noexit "C:\BIN\test.ps1" -filesArray $files" "%1"

It's basically the same command that I used for Powershell 5, just swapped pwsh in.

Unfortunately as soon as a space is encountered, it breaks:

pwsh_b756lZsQ0L

So my next thought was to use double quotes as the quote character:

"%bin%\SingleInstanceAccumulator" -q:\" "-c:pwsh -noexit "C:\BIN\test.ps1" -filesArray $files" "%1"

I escaped it with a backslash because I was getting problems. Result:

pwsh_ePJTAMyXcQ

This command is the closest I've gotten to a working solution.

I didn't get a proper array, but it did pass in a full comma delimited string of all files. I would be able to split the string via comma into a real array, but then if a file had a comma in its name, I would get invalid results.

To wrap up, I am completely stumped on how to directly pass filenames via SIA to Powershell 7. It's odd to me that it works fine in Powershell 5, but chokes on Powershell 7.

Do you have a working command that actually passes in a proper array to Pwsh 7?

Thanks for any help you can possibly give here.

Jay