將綠色軟體 (如 Unlocker、Notepad++) 整合至 Windows 右鍵選單,只需在註冊表建立對應鍵值。本文整理檔案、資料夾、磁碟機三種物件的註冊方式,並提供可直接執行的 reg add 指令。
reg add "HKEY_CLASSES_ROOT\*\shell\YourAppName\command" /ve /d "\"%%cd%%\YourApp.exe\" %%1" /f
%%cd%%:批次檔中代表腳本所在目錄 (需雙百分號跳脫)%%1:代表被右鍵點擊的檔案完整路徑reg add "HKEY_CLASSES_ROOT\Directory\shell\YourAppName\command" /ve /d "\"%%cd%%\YourApp.exe\" %%V" /f
%%V:代表被右鍵點擊的資料夾路徑reg add "HKEY_CLASSES_ROOT\Drive\shell\YourAppName\command" /ve /d "\"%%cd%%\YourApp.exe\" %%V" /f
注意:Directory 與 Drive 必須分別建立,否則磁碟機右鍵不會出現選單。
@echo off
cd /d %~dp0
rem 註冊 COM 元件 (若有)
regsvr32 /s UnlockerCOM.dll
rem 寫入解除安裝資訊 (選用)
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Unlocker" /v Language /t REG_SZ /d "2052" /f >NUL
rem 三大右鍵選單
reg add "HKEY_CLASSES_ROOT\*\shell\Unlocker 1.9.1\command" /ve /d "\"%cd%\Unlocker.exe\" %%1" /f
reg add "HKEY_CLASSES_ROOT\Directory\shell\Unlocker 1.9.1\command" /ve /d "\"%cd%\Unlocker.exe\" %%V" /f
reg add "HKEY_CLASSES_ROOT\Drive\shell\Unlocker 1.9.1\command" /ve /d "\"%cd%\Unlocker.exe\" %%V" /f
reg delete "HKEY_CLASSES_ROOT\*\shell\Unlocker 1.9.1" /f
reg delete "HKEY_CLASSES_ROOT\Directory\shell\Unlocker 1.9.1" /f
reg delete "HKEY_CLASSES_ROOT\Drive\shell\Unlocker 1.9.1" /f
HKEY_CLASSES_ROOT\Folder\shell 適用於資料夾物件,行為與 Directory 類似但範圍略有不同,建議兩者皆加。\shell\YourAppName 下新增字串值 Icon,值為 "%cd%\YourApp.exe,0"。