Hey... I think there was already thread with simillar topic. but there was nothing useful to me... so i decided to create a new topic to take help from you. Well the question is really simple. I have developed a Windows service application and console application. i am looking to launch my console application through windows service. So tell me friends if you are aware of the thing that i have posted above... Many thanks in advance...

You can, by creating a process that runs the executable, very straightforwarding. However, you may run into issues because it will not run on the logged in terminal.

Services don't run in any terminal window (your desktop) and so you will never see your app window. There is a way around this but it involves elevating priviliges, finding your terminal window and setting the service terminal as your user terminal. This is very risky and quite a large security hole/flaw. I think in Windows 7 Microsoft stopped you doing it easily through the API, I don't know about Windows 8. It's still possible in Windows 7, but I don't recommend it.

Why do you need the service to start a console app? In this case, it might be wiser to use an app that runs in the background and sits in the notification area.

Edited 3 Years Ago by Ketsuekiame

Ok thanks a lot for reply... Can you suggest some example of creating process to launch the console app??? Hope you will help me out!!! Thanks a lot again...!!!!

Simplest way is Process.Start("YourAppHere.exe");

It can get more complex if necessary, but I don't think you'd need anything else other than that.

Hey... I tried with the same but it did not worked for me at all... Can you suggest some other reply???? Anyway Thanx a lot for the reply...

Are you trying to launch it from your service still? I already told you that you won't see it appear.

To actually make it appear, you need to know how to use P/Invoke and have knowledge of the Windows API. The general suggestion is that you don't do it. If you do, you leave the system vulnerable to what's called a Shatter Attack

If you are trying to run it from a WinForms app, that way will work. Did you include the full path name of your executable?

there is no error but service is either not starting or its not working as expected...

I already mentioned that if you run it from a service you will never see it. It's not running in the same terminal window as your user account...

Hey can i start Windows form applications using windows service? the Process.Start does not seems to work anymore for me. So please suggest me some code to make the thing working.

This article has been dead for over six months. Start a new discussion instead.