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


  1. Posts : 9
    Windows 10
       #1

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


    I am creating a new right click context menu entry. It's located here: HKEY_CLASSES_ROOT\*\shell\FileUtilities\shell\a_addtofolder

    The script uses Powershell, singleinstance.exe (GitHub - zenden2k/context-menu-launcher: Select multiple files from Windows Explorer menu and launch just one instance of process), and run-hidden.exe (GitHub - stax76/run-hidden: run-hidden allows running console apps with hidden console window.), so it's gonna be a long command. :)

    Right now, this command works:
    Code:
    "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:
    Code:
    "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 > calls singleinstance.exe "%1" > calls 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)

    Could really use any help!

    Thanks much.
      My Computer


  2. Posts : 1,378
    X
       #2

    In your second code snippet ...
    The run-hidden.exe program is given 8 arguments:
    1 --> C:\Tools\scripts\singleinstance.exe
    2 --> %1
    3 --> powershell.exe
    4 --> -file
    5 --> C:\Tools\scripts\AddSelectionToFolderSI.ps1
    6 --> $files I don't know what this is.
    7 --> --si-timeout
    8 --> 250

    What does the run-hidden program do with these 8 arguments?
    Without knowing that it's not easy to find a solution.
      My Computer

  3. MaloK's Avatar
    Posts : 993
    Windows 7
       #3

    Hi,

    I cannot find Run-Hidden.exe anywhere, so it's quite difficult to try...

    Wouldn't be easier to use a Bat2Cmd utility and create an executable that run hidden, I do that often and it's very good.

    My favourite is Bat To Exe Converter (64 Bit) - Download

    Can't escape this complex command correctly so it will run properly-screenshot00042.jpg
      My Computer


  4. Posts : 9
    Windows 10
    Thread Starter
       #4

    Thanks all for the replies!

    I actually got it to work with this:

    Code:
    C:\Tools\scripts\singleinstance.exe "%1" run-hidden powershell.exe -file C:\Tools\scripts\AddSelectionToFolderSI.ps1 $files --si-timeout 250
    Many thanks to the dudes at Superuser for pointing me in the right direction. The key was putting singleinstance.exe first in the chain.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd
All times are GMT -5. The time now is 20:42.
Find Us




Windows 10 Forums