JumpServer自动打开Xshell
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\xshell]
@="URL:xshell Protocol"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\xshell\shell]
[HKEY_CLASSES_ROOT\xshell\shell\open]
[HKEY_CLASSES_ROOT\xshell\shell\open\command]
@="\"wscript.exe\" \"D:\\Softwares\\Scripts\\xshell\\open_xshell.vbs\" \"%1\""
If WScript.Arguments.Count = 0 Then WScript.Quit
Dim url
url = WScript.Arguments(0)
' ===== 新增功能:记录URL到文件 =====
Dim scriptPath, logFile, fso, fileStream, currentTime
' 获取当前脚本的完整路径
scriptPath = WScript.ScriptFullName
' 获取脚本所在的目录
scriptPath = Left(scriptPath, InStrRev(scriptPath, "\") - 1)
' 日志文件路径(在脚本同级目录下)
logFile = scriptPath & "\access.log"
' 获取当前时间
currentTime = Now()
' 创建文件系统对象
Set fso = CreateObject("Scripting.FileSystemObject")
' 以追加方式打开文件(如果文件不存在则创建)
Set fileStream = fso.OpenTextFile(logFile, 8, True)
' 写入时间戳和URL
fileStream.WriteLine "[" & currentTime & "] " & url
' 关闭文件
fileStream.Close
' 释放对象
Set fileStream = Nothing
Set fso = Nothing
' ===== 记录功能结束 =====
' 处理URL格式转换:
' 支持格式1: xshell://ssh:admin:pwd@ip:port -> ssh://admin:pwd@ip:port
' 支持格式2: xshell://admin:pwd@ip:port -> ssh://admin:pwd@ip:port
If InStr(LCase(url), "xshell://ssh://") = 1 Then
url = "ssh://" & Mid(url, 16)
ElseIf InStr(LCase(url), "xshell://ssh//") = 1 Then
url = "ssh://" & Mid(url, 15)
ElseIf InStr(LCase(url), "xshell://ssh:") = 1 Then
url = "ssh://" & Mid(url, 14)
ElseIf InStr(LCase(url), "xshell://") = 1 Then
url = "ssh://" & Mid(url, 10)
End If
' 请根据你的实际安装路径修改 Xshell.exe 的路径!
' 以下是 Xshell 7 的默认路径示例
Dim xshellPath
xshellPath = "C:\Program Files (x86)\NetSarang\Xshell 8\Xshell.exe"
Set ws = CreateObject("WScript.Shell")
' 0 表示隐藏窗口运行,避免黑框一闪而过
ws.Run """" & xshellPath & """ -url " & url, 0, False