tags:

views:

68

answers:

2

I am trying to start a process programatically from windows service written in C#. i see my process having started in the task manager but i dont see its UI.

Any idea whats going on? i am running this on windows xp

clientProcess = new System.Diagnostics.Process();
clientProcess.StartInfo.FileName = system_drive_path + @"\sd\ud\ud.exe";
clientProcess.StartInfo.WindowStyle = ProcessWindowStyle.Maximized;
clientProcess.Start();
+1  A: 

Services don't have a desktop associated with them, so when you start the GUI application, it will not show up to the user.

You need to configure the service to have interaction with the desktop, then it will work. You can do this either diagrammatically in the service installer class

Or manually in the service properties windows, under the Log On tab.

Am
+1  A: 

You are not supposed to interact with the user from a service, including starting a process. This is actually actively disallowed in Vista and later, including services marked as 'interactive', for various reasons primarily security:

Important Services cannot directly interact with a user as of Windows Vista.

If you want to interact with the user session then you must have a process in the user session (eg. a tray icon application) that interacts with the service via an IPC protocol (net pipes, shared memory, messages etc).

Create a separate UI application that runs at session start up and that application can start your 'sd.exe' when asked so by the service.

Remus Rusanu