我在pdf中创建了一个超链接,这个超链接与vbs脚本绑定,直到这一步都没问题。当我手动运行脚本(双击)时,脚本会执行我想要的操作(打开telnet连接)。问题是当我通过超链接运行脚本时,CMD显示消息“”telnet“未被识别为内部或外部命令”。拜托,谁能告诉我为什么会这样???
这是剧本:
Dim WshShell, regexp
set regular = New RegExp
direccion = inputbox("Ingresa ip del equipo:")
' Set pattern.
regular.Pattern = "^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"
' Set case insensitivity.
regular.IgnoreCase = True
' Set global applicability.
regular.Global = True
if regular.test(direccion) = TRUE then
set WshShell=CreateObject("WScript.Shell")
WshShell.run "cmd.exe"
WScript.Sleep 1000
'Send commands to the window as needed - IP and commands need to be customized
'Step 1 - Telnet to remote IP'
WshShell.SendKeys "telnet " & direccion
WshShell.SendKeys ("{Enter}")
WScript.Sleep 1000
else
msgbox "Ingresa una ip válida"
end if
答案 0 :(得分:1)
可能工作目录未正确设置。
试
WshShell.SendKeys "c:\windows\system32\telnet.exe " & direccion
p.s:你做错了。 "的SendKeys"当telnet终端已经运行时,以某种方式可以理解,但没有理由手动将密钥发送到标准命令提示符。
答案 1 :(得分:0)
Telnet不在我的Windows 10和8中。但无论如何,如果你有“telnet”命令,你不能这样做:
WshShell.run "cmd.exe /k telnet"
这应该有效并节省空间。