@ECHO OFF & PUSHD "%~DP0" && CD /D "%~DP0"
IF NOT EXIST "X:\Windows\System32\Config\System" REG QUERY "HKU\S-1-5-19" >NUL 2>&1
IF NOT %ERRORLEVEL% EQU 0 powershell.exe -windowstyle hidden -noprofile "Start-Process '%~dpnx0' -Verb RunAs" 2>NUL&EXIT

:MENU
ECHO.&ECHO  1、添加右键使用 Notepad2 打开项
ECHO.&ECHO  2、删除右键使用 Notepad2 打开项
ECHO:
set /p choice=输入数字敲回车键：
IF NOT "%choice%"=="" SET choice=%choice:~0,1%
if /i "%choice%"=="1" Goto AddMenu
if /i "%choice%"=="2" Goto RemoveMenu
ECHO 输入无效 &PAUSE>NUL&CLS&GOTO MENU
:AddMenu
reg add "HKCR\*\shell\Sublime Text" /f /v "" /d "用 &Sublime Text 打开" >NUL 2>NUL
reg add "HKCR\*\shell\Sublime Text" /f /v "Icon" /d "%~dp0sublime_text.exe" >NUL 2>NUL
reg add "HKCR\*\shell\Sublime Text\command" /f /v "" /d "%~dp0sublime_text.exe \"%%1\"" >NUL 2>NUL
ECHO.&ECHO 完成，任意键返回! &PAUSE>NUL&CLS&GOTO MENU
:RemoveMenu
reg delete "HKCR\*\shell\Sublime Text" /f >NUL 2>NUL
ECHO:&ECHO 完成，任意键返回! &PAUSE>NUL&CLS&GOTO MENU