BAT批处理设置Shift右键cmd菜单

@%1 start "" mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c""%~s0"" ::","","runas",1)(window.close)&&exit
@echo off 
@CLS
@color 0a
GOTO MENU
:MENU
ECHO.
ECHO.=-=-=-=-=菜单=-=-=-=-=
ECHO.
ECHO. 1.  修改shift右键菜单为CMD
ECHO.
ECHO. 2.  修改shift右键菜单为Powershell
ECHO. ECHO. 3. 退 出 ECHO. ECHO. ECHO. echo.请输入选择项目的序号: set id=0 set /p id= if "%id%"=="1" goto cmd1 if "%id%"=="2" goto cmd2

if "%id%"=="3" exit echo 输入的序号不能识别,请重新输入! ::pause >nul goto MENU :cmd1 echo 执行命令 在shift右键菜单中添加为CMD (REG QUERY "HKLM\SOFTWARE\Classes\Directory\background\shell\cmd" /v HideBasedOnVelocityId) >nul 2>nul if %errorlevel% == 0 ((REG DELETE "HKLM\SOFTWARE\Classes\Directory\background\shell\cmd" /v HideBasedOnVelocityId /f) >nul 2>nul) (REG QUERY "HKLM\SOFTWARE\Classes\Directory\background\shell\Powershell" /v ShowBasedOnVelocityId ) >nul 2>nul if %errorlevel% == 0 ((REG DELETE "HKLM\SOFTWARE\Classes\Directory\background\shell\Powershell" /v ShowBasedOnVelocityId /f) >nul 2>nul) rem import register file cd /d "%~dp0" (REG IMPORT ToCMD.reg) >nul 2>nul if %errorlevel% == 0 (echo 修改成功!) if %errorlevel% == 1 (echo 修改失败!) goto MENU :cmd2 echo 执行命令 在shift右键菜单中添加Powershell (REG QUERY "HKLM\SOFTWARE\Classes\Directory\background\shell\cmd" /v ShowBasedOnVelocityId) >nul 2>nul if %errorlevel% == 0 ((REG DELETE "HKLM\SOFTWARE\Classes\Directory\background\shell\cmd" /v ShowBasedOnVelocityId /f) >nul 2>nul) (REG QUERY "HKLM\SOFTWARE\Classes\Directory\background\shell\Powershell" /v HideBasedOnVelocityId) >nul 2>nul if %errorlevel% == 0 ((REG DELETE "HKLM\SOFTWARE\Classes\Directory\background\shell\Powershell" /v HideBasedOnVelocityId /f) >nul 2>nul) rem import register file cd /d "%~dp0" (REG IMPORT ToPowershell.reg) >nul 2>nul if %errorlevel% == 0 (echo 修改成功) else (echo 修改失败) GOTO MENU

 

 

ToCMD.reg

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\cmd]
@="@shell32.dll,-8506"
"Extended"=""
"NoWorkingDirectory"=""
"ShowBasedOnVelocityId"=dword:00639bc8
"Icon"="cmd.exe"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\cmd\command]
@="cmd.exe /s /k pushd \"%V\""

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\Powershell]
@="@shell32.dll,-8508"
"Extended"=""
"NoWorkingDirectory"=""
"HideBasedOnVelocityId"=dword:00639bc8

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\Powershell\command]
@="powershell.exe -noexit -command Set-Location -literalPath '%V'"

 

ToPowershell.reg

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\Powershell]
@="@shell32.dll,-8508"
"Extended"=""
"NoWorkingDirectory"=""
"HideBasedOnVelocityId"=dword:00639bc8

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\Powershell\command]
@="powershell.exe -noexit -command Set-Location -literalPath '%V'"

 

你可能感兴趣的:(BAT批处理设置Shift右键cmd菜单)