Is program running?

  • Thread starter Thread starter Joe Nollan
  • Start date Start date
J

Joe Nollan

Is there a way to determine if a program is running? My
VBA transfers some files but will crash if the other
program is using the files. The other program is started
with SHELL but could have been started from the start menu
also.
 
I don't know how you open the file but it should be possible to open the
file using a sharing mode that causes the open to fail with a meaningful
error code if another process has it open. You should be using a relevant
sharing code and checking the error codes from open anyway. However it is
also a good idea to wait on the other program as you are asking about.

For scripting purposes, WMI can be very useful and powerful. You can use WMI
to monitor the other process. The following is not about just WMI, but WMI
is used so much that it is very relevant.

http://www.microsoft.com/technet/community/scriptcenter/default.mspx

Two things in particular to look at is the "Download all the scripts in HTML
Help format" and the "Scriptomatic". The scripts that can be downloaded are
also available for online viewing. The following are more specific places to
look for some relevant samples.

http://www.microsoft.com/technet/community/scriptcenter/process/default.mspx
http://www.microsoft.com/technet/community/scriptcenter/monitor/default.mspx

If you can't find a more appropriate solution using WMI, you can probably do
what you need to do by monitoring process deletion.

WMI is quite easy to use in scripts, and once you are familiar with it,
there is a lot that you can do.
 
Back
Top