【问题标题】:How to run telnet in silent mode using VB script?如何使用 VB 脚本在静默模式下运行 telnet?
【发布时间】:2014-03-31 17:43:50
【问题描述】:

我是 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
...

【问题讨论】:

    标签: vbscript


    【解决方案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
    

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2014-03-15
        • 2019-03-15
        • 2010-09-29
        • 2017-05-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多