请参阅 GitHub SingleInstanceAccumulator,了解 C# 实现的陈旧的 Mutex + COPYDATA 方法。
other stack-o's表达需求。
资源管理器上下文菜单配置
::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***"
例如在我的系统上,对于“.mov”文件,我会将上面的 FileType 替换为 VLC.mov
复杂的 REG ADD 示例
将上面的“* see command line examples *”替换为您想要的命令行。
注意:quotes & environment variables 必须被转义,并且对于初始命令和字符串后面的命令,转义工作略有不同!?!
λ 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 用法
"-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
命令行示例
注意:初始命令必须有路径,shell > 命令才能工作
PowerShell 和临时文件
注意:-f用法
"%bin%\SingleInstanceAccumulator" -f "-c:powershell -ExecutionPolicy bypass "%bin%\test.ps1" -list '$files'" "%1"
PowerShell & 内联 文件列表
注意:-q用法
"%bin%\SingleInstanceAccumulator" -q:' "-c:powershell -ExecutionPolicy bypass "%bin%\test.ps1" -list $files" "%1"
test.ps1(带有临时文件)
powershell
param(
[String]$listFilePath
)
gc $listFilePath | % { $_ }
pause
erase $listFilePath
pause
test.ps1(带有文件数组参数)
param(
[String[]]$filesList
)
$filesList | % { $_ }
pause