run a batch file at folder's context menu.shell
add a right click menu action that runs a custom batch script.命令行
本篇無知識點,只是將前面寫的,弄到右鍵菜單,方便隨時調用。code
對之前批處理代碼進行調整,主要是對進入的目錄參數進行調整。ip
這裏要把一個批處理文件作兩份處理:
set "HandleDir=%~1"
對應到HKEY_CLASSES_ROOT\Directory\shell\
;
set "HandleDir=%cd%"
對應到HKEY_CLASSES_ROOT\Directory\Background\
。get
執行時分別爲
@="cmd.exe /c C:\\bat\\dir.bat %1 \"%V\""
;
@="cmd.exe /c C:\\bat\\dir-bg.bat %cd% \"%V\""
cmd
我這裏是將處理以後的批處理文件放在了C:\bat
這裏不貼代碼了,點擊連接下載查看源碼源碼
file.bat
, file-bg.bat
dir.bat
, dir-bg.bat
name.bat
, name-bg.bat
保存並執行下面文件和目錄命名操做.reg
文件,而後在目標目錄鼠標右鍵就能夠選擇相關操做項了。it
Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\Directory\shell\xfiles] @="文件命名操做(&A)" "NoWorkingDirectory"="" [HKEY_CLASSES_ROOT\Directory\shell\xfiles\command] @="cmd.exe /c C:\\bat\\file.bat %1 \"%V\"" [HKEY_CLASSES_ROOT\Directory\Background\shell] [HKEY_CLASSES_ROOT\Directory\Background\shell\xfiles] @="文件命名操做(&A)" [HKEY_CLASSES_ROOT\Directory\Background\shell\xfiles\command] @="cmd.exe /c C:\\bat\\file-bg.bat %cd% \"%V\"" [HKEY_CLASSES_ROOT\Directory\shell\xdir] @="目錄命名操做(&Q)" "NoWorkingDirectory"="" [HKEY_CLASSES_ROOT\Directory\shell\xdir\command] @="cmd.exe /c C:\\bat\\dir.bat %1 \"%V\"" [HKEY_CLASSES_ROOT\Directory\Background\shell] [HKEY_CLASSES_ROOT\Directory\Background\shell\xdir] @="目錄命名操做(&Q)" [HKEY_CLASSES_ROOT\Directory\Background\shell\xdir\command] @="cmd.exe /c C:\\bat\\dir-bg.bat %cd% \"%V\"" [HKEY_CLASSES_ROOT\Directory\shell\xfiledirname] @="文件和目錄名(&Z)" "NoWorkingDirectory"="" [HKEY_CLASSES_ROOT\Directory\shell\xfiledirname\command] @="cmd.exe /c C:\\bat\\name.bat %1 \"%V\"" [HKEY_CLASSES_ROOT\Directory\Background\shell] [HKEY_CLASSES_ROOT\Directory\Background\shell\xfiledirname] @="文件和目錄名(&Z)" [HKEY_CLASSES_ROOT\Directory\Background\shell\xfiledirname\command] @="cmd.exe /c C:\\bat\\name-bg.bat %cd% \"%V\""
右鍵菜單添加命令行入口.reg
保存並執行,在任何目錄便可調用cmd。此功能跟批處理不要緊,可忽略。io
Windows Registry Editor Version 5.00 ;[-HKEY_CLASSES_ROOT\Directory\shell\xcmd] ;[-HKEY_CLASSES_ROOT\Directory\Background\shell\xcmd] ;[-HKEY_CLASSES_ROOT\Drive\shell\xcmd] ;[-HKEY_CLASSES_ROOT\LibraryFolder\background\shell\xcmd] [HKEY_CLASSES_ROOT\Directory\shell\xcmd] @="CLI" [HKEY_CLASSES_ROOT\Directory\shell\xcmd\command] @="cmd.exe /s /k pushd \"%V\"" [HKEY_CLASSES_ROOT\Drive\shell\xcmd] @="CLI" [HKEY_CLASSES_ROOT\Drive\shell\xcmd\command] @="cmd.exe /s /k pushd \"%V\"" [HKEY_CLASSES_ROOT\Directory\Background\shell] [HKEY_CLASSES_ROOT\Directory\Background\shell\xcmd] @="CLI" [HKEY_CLASSES_ROOT\Directory\Background\shell\xcmd\command] @="cmd.exe /s /k pushd \"%V\"" [HKEY_CLASSES_ROOT\LibraryFolder\background\shell\xcmd] @="CLI管理員(&X)" [HKEY_CLASSES_ROOT\LibraryFolder\background\shell\xcmd\command] @="cmd.exe /s /k pushd \"%V\"" ;[-HKEY_CLASSES_ROOT\Directory\shell\runas] ;[-HKEY_CLASSES_ROOT\Directory\Background\shell\runas] ;[-HKEY_CLASSES_ROOT\Drive\shell\runas] ;[-HKEY_CLASSES_ROOT\LibraryFolder\background\shell\runas] [HKEY_CLASSES_ROOT\Directory\shell\runas] @="CLI管理員(&X)" "HasLUAShield"="" [HKEY_CLASSES_ROOT\Directory\shell\runas\command] @="cmd.exe /s /k pushd \"%V\"" [HKEY_CLASSES_ROOT\Directory\Background\shell\runas] @="CLI管理員(&X)" "HasLUAShield"="" [HKEY_CLASSES_ROOT\Directory\Background\shell\runas\command] @="cmd.exe /s /k pushd \"%V\"" [HKEY_CLASSES_ROOT\Drive\shell\runas] @="CLI管理員(&X)" "HasLUAShield"="" [HKEY_CLASSES_ROOT\Drive\shell\runas\command] @="cmd.exe /s /k pushd \"%V\"" [HKEY_CLASSES_ROOT\LibraryFolder\background\shell\runas] "HasLUAShield"="" @="CLI管理員(&X)" [HKEY_CLASSES_ROOT\LibraryFolder\background\shell\runas\command] @="cmd.exe /s /k pushd \"%V\""
轉載保留原文地址和做者名,只爲錯誤勘正和信息補充。
版權聲明:自由轉載-非商用-非衍生-保持署名(創意共享3.0許可證)cli