We help IT Professionals succeed at work.

Windows Service

tbaseflug
tbaseflug asked
on
234 Views
Last Modified: 2010-04-15
Am trying to figure out how I would start a process at the following location: "C:\Program Files\Network Associates\VirusScan\mcupdate.exe"

I need to check and see if the process is started.  if not start it, execute, then stop when completed - any help would save my day!!!!
Comment
Watch Question

Commented:
Check out the System.Diagnostics namespace.

Here's a link to the Process class and its Start Method.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdiagnosticsprocessclassstarttopic.asp

And the GetProcesses static method which will tell you what's currently running...

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdiagnosticsprocessclassgetprocessestopic.asp
tbaseflug,

  Go to this page: http://msdn.microsoft.com/vcsharp/downloads/samples/23samples/default.aspx.  You will see an item called "Interacting with a Windows Service in C#".  Download the sample code, and take a look - I think that is more what you are looking for.

Author

Commented:
eternal_21 -

This does seem closer to what I am looking for - any idea on wether the same concept can applied to a process as opposed to a service - in the ability to start and stop?
If you want to start and stop a process, this can all be done through the System.Diagnostics.Process class (as dfiala13 suggested).

Commented:
You cannot start or stop a service with those methods. But you can use them to check if it's running. Use the ServiceController to stop and start services.

Author

Commented:
ptmcomp -

Can you give me a quick code-level example?
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.