Can't escape this complex command correctly so it will run properly from the registry

I am creating a new right click context menu entry for all files. It's located here:

HKEY_CLASSES_ROOT\*\shell\FileUtilities\shell\a_addtofolder

It basically just adds selected files to a new folder. I know the function is rudimentary but this is a learning experience.

The script uses Powershell, singleinstance.exe (https://github.com/zenden2k/context-menu-launcher), and run-hidden.exe (https://github.com/stax76/run-hidden), so it's gonna be a long command. :)

Right now, this command works:

"C:\Tools\scripts\singleinstance.exe" "%1" "powershell.exe" -file "C:\Tools\scripts\AddSelectionToFolderSI.ps1" $files --si-timeout 250

This is what I need, but it doesn't work:

"C:\Tools\scripts\PATH\run-hidden.exe" "C:\Tools\scripts\singleinstance.exe" "%1" "powershell.exe" -file "C:\Tools\scripts\AddSelectionToFolderSI.ps1" $files --si-timeout 250

Logically this is what I want to happen:

run-hidden.exe > singleinstance.exe "%1" > powershell.exe -file "C:\Tools\scripts\AddSelectionToFolderSI.ps1" $files > --si-timeout 250

--si-timeout 250 is an argument associated with singleinstance.exe. It's a short timer to allow multiple files to be passed to PowerShell (kind of like if the script was called from the SendTo menu)

I have tried so many different combinations of single and double quotes and I'm just lost.

If anyone can please help, it would be a godsend.

Thanks so much.


The answer was to put the run-hidden.exe call inside the singleinstance.exe call, like this:

C:\Tools\scripts\singleinstance.exe "%1" "C:\Tools\scripts\PATH\run-hidden.exe" powershell.exe -file C:\Tools\scripts\AddSelectionToFolderSI.ps1 $files --si-timeout 250