Excel VBA – 停止运行由Shell启动的程序?
Excel 2002 VBA。
我有一个macros启动一个外部脚本,只要满足一定的条件:
Shell("c:\program\script.exe")
条件不满足时,如何停止正在运行的程序?
由于Shell返回您开始的进程的进程ID,您可以尝试使用pskill和该进程ID来停止它:
dim pid pid = Shell("c:\program\script.exe") '...Do something Shell "pskill " & pid
Shell参考: http : //msdn.microsoft.com/en-us/library/xe736fyk(VS.71).aspx