|
以下是我在用的,集成到右键菜单很方便,不推荐用VBS,因为cmd的文本处理功能更强大。
读取剪贴板内容用PS有点慢,胜在是系统自带的,用第三方命令工具winclip 会快很多,也会支持PE。
- :: 定位剪贴板中的注册表路径
- for /f "delims=" %%a in ('powershell -noprofile -command "Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.Clipboard]::GetText()"') do set "regpath=%%a"
- set regpath=%regpath:[=%
- set regpath=%regpath:]=%
- set regpath=%regpath:"=%
- set regpath=%regpath:计算机\=%
- :space
- if "%regpath:~-1,1%"==" " (
- set regpath=%regpath:~0,-1%
- goto space
- )
- reg query "%regpath%"
- if %ERRORLEVEL% neq 0 goto error
- reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit" /v "LastKey" /t REG_SZ /d "%regpath%" /f
- taskkill /f /im regedit.exe
- start regedit.exe
- exit
- :error
- msg %username% /time:5 经过查询,注册表项不存在,请仔细检查。
复制代码 |
|