hi to all, i am new to .Net Development. My requirement was executing an application whenever the service starts. i need to do it in C#. please help.i dont know how to do that . if u have any reference specify that also.
thanks in advance
hi to all, i am new to .Net Development. My requirement was executing an application whenever the service starts. i need to do it in C#. please help.i dont know how to do that . if u have any reference specify that also.
thanks in advance
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Scott LyslePosted Feb 13, 2008, 4:18 AM
You can start by overriding the OnStart event for your service; in that code you can use Process.Start to kick on some other application (in the below example, I start internet explorer and pass it the URL for MSN as a argument so that whenever the service starts, it opens up MSN in an explorer window)
protected override void OnStart(string[] args) { System.Diagnostics.Process.Start("iexplore.exe", "http://www.msn.com"); }Process.Start accepts a couple of arguments, the first is the executable to launch (e.g., iexplore.exe in this example) and the second argument is any optional arguments that the executable may use (in this case, a URL). Of course the executable can be any executable and may include a full path to that executable and the arguments to the executable are optional.