使用VBscript / Wscript进行Telnet重置

时间:2012-01-25 17:18:51

标签: vbscript telnet wsh

此VBSCRIPT代码会引发800A0400错误。有什么想法吗?

<job>
<script language="VBScript">
Option Explicit
On Error Resume Next
Dim WshShell
set WshShell=CreateObject("WScript.Shell")
WshShell.run "cmd.exe"
WScript.Sleep 500
'Send commands to the window as needed - IP and commands need to be customized
'Step 1 - Telnet to remote IP'
WshShell.SendKeys "telnet 123.456.789.01"
WshShell.SendKeys ("{Enter}")
WScript.Sleep 500
'Step 2 - Issue Commands with pauses'
'USERNAME
WshShell.SendKeys "USERNAMEHERE"
WshShell.SendKeys ("{Enter}")
WScript.Sleep 500
'PASSWORD
WshShell.SendKeys "PASSWORDHERE"
WshShell.SendKeys ("{Enter}")
WScript.Sleep 500
'RESET
WshShell.SendKeys "reset"
WshShell.SendKeys ("{Enter}")
WScript.Sleep 500
'CONFIRM
WshShell.SendKeys "y"
WshShell.SendKeys ("{Enter}")
WScript.Sleep 500
'Step 3 - Exit Command Window
WshShell.SendKeys "exit"
WshShell.SendKeys ("{Enter}")
WScript.Quit 
</script>
</job>

1 个答案:

答案 0 :(得分:1)

您是否曾尝试谷歌获取您获得的错误代码或脚本文件XML语法?您缺少<package>根元素,可能是文件扩展名错误(应该是.wsf)。