VBScript - 创建并使用隐藏窗口杀死进程?

时间:2014-09-23 22:15:40

标签: windows ssh vbscript

我有这个简单的脚本帮助我的一些用户通过VNC SSH连接到服务器上的非托管帐户。我正在使用Putty和TightVNC,它们都与脚本位于同一目录中。它是这样的:

Dim sshtunnel
Dim desktop

Set tunnel = WScript.CreateObject("WScript.Shell")
Return = tunnel.run("putty -ssh user@#.#.#.# -L 9000:localhost:5901 -pw password",0,false)
Set desktop = WScript.CreateObject("WScript.Shell")
Return = desktop.run("tvnviewer -host=localhost -port=9000",0,true)
'Somehow, end the process created by tunnel.run

步骤:
1.)以不可见的方式启动Putty并进行适当的端口转发(工作
2.)启动远程桌面(工作
3.)等待远程桌面会话关闭(工作
4。)关闭SSH隧道(kill putty)(需要帮助

显然,我需要它来杀死Putty - 但我找不到任何方式与以tunnel.run方法开始的进程进行通信。我找不到使用exec隐藏创建流程的方法。我该怎么做呢?

谢谢!
PS:我知道有一个硬编码的密码。在这种情况下,在部署时纠正这种情况更为合适。

1 个答案:

答案 0 :(得分:1)

很多方面。适合你正在做的事情就是运行taskkill。

Return = tunnel.run("taskkill /im PuTTY.exe /f",0,false)

Return = tunnel.run("wmic process where (Name=""PuTTY.exe"") call terminate",0,false)
相关问题