windows service with process.start()

  • Thread starter Thread starter uuyytt
  • Start date Start date
U

uuyytt

I have a Windows service from which I want to start Internet Explorer with a
particular URL as an argument. I don't know why my code (shown below)
doesn't work. I know that IExplore.exe starts as I can see it in my task
manager, but it is not visible. Can anyone explain what is happening?

My code:
Process p = Process.Start("IExplore.exe", m_strURL);
 
Hi,

uuyytt said:
I have a Windows service from which I want to start Internet Explorer with
a particular URL as an argument. I don't know why my code (shown below)
doesn't work. I know that IExplore.exe starts as I can see it in my task
manager, but it is not visible. Can anyone explain what is happening?

My code:
Process p = Process.Start("IExplore.exe", m_strURL);

NT Services do not have access to the interactive desktop by default.
Windows NT and above have the concept of window stations. Your logon session
has a window station and your service has its own. So they both have a
windows desktop of their own and you can only see yours. If your service
runs as local system you can use service control manager to give that
service access to the interactive desktop. So that might help but only for a
little while I guess because if you connect to that server with remote
desktop your remote session will live in just another window station.

My advice is to change your design. Split up your service's functionality to
start processes in another app which is run manually by the user. You might
add it to the startup group to get it auto started after a user logged in.
Then use some IPC mechanism (remoting, sockets, COM) to communicate between
your service and the user app, so that the service can tell your user app to
start some processes.
 
I have the same problem with windows service. When i run
Process.Start("notepad.exe"), I cant open a notepad but I see the process is
running in task manager.

Event I allow services explicitly to interact with the desktop.

PS. This problem occur only on windows 2003
 
Hi,

uuyytt said:
I have the same problem with windows service. When i run
Process.Start("notepad.exe"), I cant open a notepad but I see the process
is running in task manager.

Event I allow services explicitly to interact with the desktop.

PS. This problem occur only on windows 2003

Are you seeing the server directly or with remote desktop client?
Please verify which session your logon is running in: Task
manager->Processes: Menu: View->Select Columens... "Session ID"

Both your service and your login session should be 0.
 
I remote to desktop client and see both service has Session ID = 0.

I allowed services explicitly to interact with the desktop and
I tested with imporsonation but still not work.


Any idea?
 
Hi,

uuyytt said:
I remote to desktop client and see both service has Session ID = 0.

Both service? Do you have two services or do you mean your service and the
started application (e.g. IE or notepad) have both session 0?
If that is the case your started app will only be visible when you log on
directly at the console of the server where you also get to session 0. On
your remote session you could look up the session ID of explorer.exe which
will be > 0.
I allowed services explicitly to interact with the desktop and
I tested with imporsonation but still not work.

You can try if you can connect with the command "mstsc /console" which
connects you to session 0. But only one user can connect to that session so
this does not work if more than one user uses the "app start feature" of
your service as all started apps will appear in session 0.
 
Back
Top