471,627 Members | 1,269 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,627 software developers and data experts.

Easy way to tell if a program is running.

UJ
I am writing an automatic download process that will update software on a
computer. We've got services that run all of the time and a couple of
programs that run all of the time. How can I tell if the program/service is
running so I can stop it, update it and restart it?

TIA - Jeff.
Feb 7 '06 #1
2 1397
UJ,
I guess the easies way would be to try updting (replacing the files) if the
the program/service is running you will get an excpetion that the file you
are trying to replace is locked (used at the moment). Collect all such
failed updates and ask the user to stop problematic applications or if it is
possible stop them by yourself. You can also rename the files that has been
in use (you can do that even if the file is locked in the memory) and copy
the new ones. When the installation is done ask the user to restart the
machine. You need to have a mechanism to delete the old renamed files ones
the system is up and running again.

Other solution would be to use the Process class to check out all running
processes at the moment.
--

Stoitcho Goutsev (100)

"UJ" <fr**@nowhere.com> wrote in message
news:O6***************@TK2MSFTNGP15.phx.gbl...
I am writing an automatic download process that will update software on a
computer. We've got services that run all of the time and a couple of
programs that run all of the time. How can I tell if the program/service is
running so I can stop it, update it and restart it?

TIA - Jeff.

Feb 7 '06 #2
Hi,

The services are easy to tell, all you have to do is use ServiceController
class to tell the status.

Regarding the running programs you could just follow Stoitcho's suggestion ,
or alternatively you could create a unique object in the system and check
for it (a common techinque to assure only one instance of an app is run)

Then you could send a message to the running process for it to terminate
gracefuly.
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"UJ" <fr**@nowhere.com> wrote in message
news:O6***************@TK2MSFTNGP15.phx.gbl...
I am writing an automatic download process that will update software on a
computer. We've got services that run all of the time and a couple of
programs that run all of the time. How can I tell if the program/service is
running so I can stop it, update it and restart it?

TIA - Jeff.

Feb 7 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Ang Talunin | last post: by
8 posts views Thread by Xero Limit 126 | last post: by
9 posts views Thread by Hans-Joachim Widmaier | last post: by
2 posts views Thread by Robert D. Young | last post: by
12 posts views Thread by Robert Mark Bram | last post: by
1 post views Thread by Terry Olsen | last post: by
16 posts views Thread by Michael | last post: by
4 posts views Thread by Rick Stevens | last post: by
1 post views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.