2013-05-05 39 views
0

當我運行下面的VB腳本時,我得到了預期的輸出。在vbscript後殺死Winword.exe

但是,一個新的winword.exe進程運行,我想殺死腳本結束後。

Set Wshshell= CreateObject("Word.Basic") 
WshShell.sendkeys"%{prtsc}" 
WScript.Sleep 1500 
Set wshshell = Nothing 

set WshShell = WScript.CreateObject("WScript.Shell") 
WshShell.Run "mspaint" 
WScript.Sleep 1000 
Set wshshell = Nothing 

Set Wshshell= CreateObject("Word.Basic") 
WshShell.AppActivate "Paint" 
WScript.Sleep 2000 

WshShell.sendkeys"^(v)" 
WScript.Sleep 1000 

WshShell.sendkeys"^(s)" 
WScript.Sleep 1500 

WshShell.sendkeys"c:\testing.jpg" 
WScript.Sleep 500 
WshShell.sendkeys "{Enter}" 

Set wshshell = Nothing 

回答

2

您必須關閉使用

Wshshell.FileClose 

Wshshell.AppClose 
+0

活動過程中同時加入了上面的代碼,它說「無法關閉窗口,因爲它不是一個活躍的」 – 2013-05-05 16:51:57

+0

偉大的「Wshshell.AppClose」幫助殺死了創建的進程。 謝謝:) – 2013-05-05 17:04:05