Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Shell still running?
Hi,
I wonder if it's possible to check if an external command is still running, using the Shell-function. Here's my code (vCmd = dos-program): vID = Shell(vCmd, vbMinimizedNoFocus) is it possible to use vID in order to see if the dos-command is still open? Thanks, Jos Vens |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Shell still running?
Jos,
Here is an example of something you can modify that should work. In my example, the first message box was used to make sure I gave enough time for Notepad to actually open before the remaining code checked for the process ID. In practice, you probably won't need it. I also had Notepad open in a normal window with focus for purposes of testing but you can easily modify. '---------------------------------------------- Sub StartProcessThenCheck() Dim objWMI As Object Dim colProcesses As Object Dim objProcess As Object Dim vID As Variant vID = Shell("C:\Windows\Notepad.exe", 1) MsgBox "A new notepad process has been started" Set objWMI = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\.\root\cim v2") Set colProcesses = objWMI.ExecQuery _ ("Select * from Win32_Process") For Each objProcess In colProcesses If objProcess.ProcessID = vID Then MsgBox "The instance of Notepad you just started is still running" End If Next objProcess Set objWMI = Nothing Set colProcesses = Nothing Set objProcess = Nothing End Sub '--------------------------------------------- Steve Yandl "Jos Vens" wrote in message ... Hi, I wonder if it's possible to check if an external command is still running, using the Shell-function. Here's my code (vCmd = dos-program): vID = Shell(vCmd, vbMinimizedNoFocus) is it possible to use vID in order to see if the dos-command is still open? Thanks, Jos Vens |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Running A Shell Command In VBA | Excel Programming | |||
Running Shell | Excel Discussion (Misc queries) | |||
running two separate commands in same Shell | Excel Programming | |||
running commands from hte shell | Excel Programming | |||
shell command running very slow | Excel Programming |