|
- Option Explicit
- Dim objShell, userInput, regPath
- Set objShell = CreateObject("WScript.Shell")
- ' 获取用户输入的注册表路径
- userInput = InputBox("请输入注册表路径(例如:HKEY_LOCAL_MACHINE\SOFTWARE):", "注册表路径跳转工具")
- ' 用户取消操作时退出
- If userInput = "" Then WScript.Quit
- ' 格式化路径为注册表编辑器可识别的格式
- regPath = "计算机" & Replace(userInput, "HKEY_", "HKEY_", 1, -1, vbTextCompare)
- ' 关闭可能存在的注册表编辑器进程
- objShell.Run "taskkill /f /im regedit.exe > nul", 0, True
- ' 写入最后访问路径到注册表
- On Error Resume Next
- objShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit\LastKey", regPath, "REG_SZ"
- If Err.Number <> 0 Then
- MsgBox "路径写入失败,请检查:" & vbCrLf & _
- "1. 输入的路径格式是否正确" & vbCrLf & _
- "2. 是否具有管理员权限", vbCritical, "错误"
- WScript.Quit
- End If
- ' 启动注册表编辑器
- objShell.Run "regedit.exe", 1, False
- ' 清理操作(可选)
- ' objShell.RegDelete "HKCU\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit\LastKey"
- MsgBox "已成功跳转到:" & vbCrLf & userInput, vbInformation, "操作完成"
复制代码
保存成VBS即可,注意编码格式ANSI
|
|