First of all I would like to thank every one who has tried to help me thus far, it great! As I said im a noob at c# getting this type of help will bring me to the next level (even if its a still a low one ;)) I'm am using vista.... when using Shukla's great piece of code I get this: The problem might be missing a reference? Error 1 The type or namespace name 'ServiceProcess' does not exist in the namespace 'System' (are you missing an assembly reference?) C:\Users\mike\AppData\Local\Temporary Projects\ConsoleApplication1\Program.cs 2 14 ConsoleApplication1 The problem might be missing a reference? Also the ebook (Microsoft.Press.Microsoft.Visual.C.Sharp.2008.Step.by.Step)I use to teach myself is not telling me how to link in a external .dll so if you have any good references on this subject I would love to know! Anyway thank you for you time! :-D
Whitaker Mike
Posts
-
Windows Service Controlle in VS2008 -
Windows Service Controlle in VS2008Hi, I hope some one out there can help me! I have been goggling my brains out all day tiring to find the answer for this question I have: I'm using visual studio 2008 and I am pretty much a noob to c#. So go easy on me. Trying to write a console app that checks the status of a windows service and if it is up stops it and if it's down brings it up! But the problem is that the book I am using to teach myself c# in vs 2008 does not describe this. And also to code that I do find on the web is for 2005 and doesn't work in 2008! I might look a bit liker this: public static void StartService(string serviceName, int timeoutMilliseconds) { ServiceController service = new ServiceController(serviceName); try { TimeSpan timeout = TimeSpan.FromMilliseconds(timeoutMilliseconds); service.Start(); service.WaitForStatus(ServiceControllerStatus.Running, timeout); } catch { // ... } } But as I stated earlier the ServiceController class doesn't seem to work in 2008, or I could just be a dim whit... So any idea you might have as of how I might do this would make my day! Thanks in advice, Mike