2014-09-23 77 views
0

我有这个简单的脚本,帮助我的一些用户将SSH通过VNC转换为服务器上的非专用帐户。我正在使用Putty和TightVNC,它们与脚本位于同一目录中。它是这样的:VBScript - 创建并在一个隐藏的窗口中杀死一个进程?

Dim sshtunnel 
Dim desktop 

Set tunnel = WScript.CreateObject("WScript.Shell") 
Return = tunnel.run("putty -ssh [email protected]#.#.#.# -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)开始腻子用适当的端口转发无形(工作
2)启动远程桌面(工作
3)等待远程桌面会话被关闭(作品
4)关闭SSH隧道(杀腻子)(需要帮助

很显然,我需要它来杀死腻子 - 但我找不到任何方式与以tunnel.run方法开始的进程进行通信。我无法找到一种方法来使用exec隐形进行创建。我应该如何处理这个问题?

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

回答

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)