How to add new items to right-click event on Folders and Files in Windows?

后端 未结 4 2053
一个人的身影
一个人的身影 2020-12-03 04:14

I did google couple of tutorials on google.

I am able to add right-click menu item to a FOLDER by doing this:

[HKEY_CLASSES_ROOT\\Di         


        
4条回答
  •  天涯浪人
    2020-12-03 04:37

    See GitHub SingleInstanceAccumulator for a C# implementation of the well worn Mutex + COPYDATA approach to this.

    other stack-o's expressing the need.

    Explorer Context Menu config

    ::creates the entry
    :: and crucial multi-file handling property
    reg add "HKEY_CLASSES_ROOT\FileType\shell\YourNewContextMenu" /f /v "MultiSelectModel" /d "Player"
    
    ::your desired command line
    reg add "HKEY_CLASSES_ROOT\FileType\shell\YourNewContextMenu\command" /f /ve /t REG_EXPAND_SZ /d "***see command line examples***"
    

    e.g. On my system, for ".mov" files, I would replace FileType above with VLC.mov

    Complex REG ADD example

    Replace "* see command line examples *" above with your desired command line.
    Note: quotes & environment variables must be escaped and escaping work slightly differently for the initial command versus later in the string!?!

    λ reg add "HKEY_CLASSES_ROOT\VLC.mov\shell\Transcode\command" /f /ve /t REG_EXPAND_SZ /d "\"^%bin^%\SingleInstanceAccumulator\" -f \"-c:powershell -ExecutionPolicy bypass "\"^%bin^%\test.ps1\"" -list '$files'\" \"%1\""
    

    SingleInstanceAccumulator.exe Usage

    "-c:command line" (default: cmd /c echo $files && pause)
      $files will be replace with aggregated list
    
    -f = output each item on separate line to new tempfile
      $files will be replaced by the tempfile path
      quote will default to nothing
    
    -d:delimiter (default: ,)
    -q:quote (default: ")
    -t:timeout millisecs (default: 200)
    -w = hidden launch
    -v = debug output
    

    Command Line Examples

    note: initial command must have path for shell > command to work

    PowerShell & temp file

    note: -f usage

    "%bin%\SingleInstanceAccumulator" -f "-c:powershell -ExecutionPolicy bypass "%bin%\test.ps1" -list '$files'" "%1"
    

    PowerShell & inline files list

    note: -q usage

    "%bin%\SingleInstanceAccumulator" -q:' "-c:powershell -ExecutionPolicy bypass "%bin%\test.ps1" -list $files" "%1"
    

    test.ps1 (with temp file)

    powershell
    param(
      [String]$listFilePath
    )
    
    gc $listFilePath | % { $_ }
    
    pause
    
    erase $listFilePath
    
    pause
    

    test.ps1 (with files array parm)

    param(
      [String[]]$filesList
    )
    
    $filesList | % { $_ }
    
    pause
    

提交回复
热议问题