1

Possible Duplicate:
How to start a process from windows service into currently logged in user’s session
c# windows service

I have this code in the OnStart Method of the windows service.

System.Diagnostics.Process.Start("notepad.exe");

I am successfully able to start the windows service. However once the service has successfully started it doesn't open the notepad.

This is a strange problem and as i am new to windows services, help is required.

Community
  • 1
  • 1
Win Coder
  • 6,628
  • 11
  • 54
  • 81

1 Answers1

3

Windows services don't execute in the same context as the desktop.

Hence you won't see the application running in explorer like you would if you launched it normally.

scartag
  • 17,548
  • 3
  • 48
  • 52
  • @WinCoder i'm tempted to ask why you'd want a windows service to start notepad (or any other app) You may be better of using regular exe and setting task scheduler to run it at intervals. – scartag Jan 09 '13 at 20:36
  • just started learning windows service and wanted to do different things with it, didn't knew that this simple task was hard as hell. – Win Coder Jan 09 '13 at 20:37
  • @WinCoder It's not really difficult, just impossible .. by design. – scartag Jan 09 '13 at 20:38
  • hmmm well i guess can't do it then....and i suppose i won't be able to disply a textbox either would i ? – Win Coder Jan 09 '13 at 20:40
  • Write an event to the event log if you want to know if your service started. – StarPilot Jan 09 '13 at 21:09