3

我是 VB 脚本的新手。实际上我想运行一些应用服务器的 telnet 命令。

我正在我的客户端 PC(操作系统:- Windows server 2003)上运行该 VB 脚本。该脚本运行良好。

现在的问题是,当 telnet 通过 VB 脚本运行时,我对此无能为力

个人电脑。我希望该脚本在后端运行。即在静音模式下。

以下是我正在使用的 VB 代码。

set oShell = CreateObject("WScript.Shell")
oShell.run"cmd.exe"
WScript.Sleep 500
oShell.SendKeys"telnet x.x.x.x -f roamingsubscriber.txt"
oShell.SendKeys("{Enter}")
WScript.Sleep 1500
oShell.SendKeys"username"
oShell.SendKeys("{Enter}")
WScript.Sleep 500
oShell.SendKeys"password"
oShell.SendKeys("{Enter}")
WScript.Sleep 500
oShell.SendKeys"command"
oShell.SendKeys("{Enter}")
WScript.Sleep 1000
oShell.SendKeys"command"
oShell.SendKeys("{Enter}")
WScript.Sleep 1000
...
4

2 回答 2

1

http://www.dimac.net/default3.asp?M=FreeDownloads/Menu.asp&P=FreeDownloads/FreeDownloadsstart.asp有关执行此类操作的免费 ActiveX 组件,请参阅此站点。这是API

http://www.dimac.net/products/freeproducts/w3sockets/reference/refstart.htm

这里有一些示例代码

Set oSocket = WScript.CreateObject("Socket.TCP")
oSocket.DoTelnetemulation = True
osocket.Timeout = 1000
oSocket.Host = "host.somewhere.com" & ":" & 80
oSocket.Open
oSocket.SendLine("GET /" & vbCrLf)
data = oSocket.GetLine
If (Instr(data, "yourtest")) then
    ' doSomething
End if
oSocket.Close
于 2012-09-24T11:24:19.617 回答
0

除非您找到或开发一个ActiveX组件,该组件将在telnet不创建控制台窗口并将其输入和输出通过管道传输的情况下启动进程,否则无法完成您的任务。至少WScript.Shell不提供这样的功能。

于 2012-09-22T19:29:22.487 回答