Excel VBA-停止运行由Shell启动的程序吗? [英] Excel VBA - Stop running program that was started by Shell?
本文介绍了Excel VBA-停止运行由Shell启动的程序吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Excel 2002 VBA.
Excel 2002 VBA.
我有一个宏,只要满足特定条件,该宏就会启动一个外部脚本:
I have a macro that launches an external script whenever a certain condition is met:
Shell("c:\program\script.exe")
在不满足条件的情况下如何停止正在运行的程序?
How do I stop that running program when the condition is not met?
推荐答案
由于Shell返回了您启动的进程的进程ID,因此您可以尝试使用带有该经过处理的ID的pskill来停止它:
Since Shell returns the process ID of the process you started you could try using pskill with that procedd ID to stop it:
dim pid
pid = Shell("c:\program\script.exe")
'...Do something
Shell "pskill " & pid
Shell参考: https://docs. microsoft.com/en-us/office/vba/language/reference/user-interface-help/shell-function
Shell reference: https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/shell-function
这篇关于Excel VBA-停止运行由Shell启动的程序吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文