-2

I have a created window service and installed successfully. I have enclosed a exe file in service but it does not start .exe.

 Protected Overrides Sub OnStart(ByVal args() As String)
 System.Diagnostics.Process.Start("C:\Users\Dr.Fazan\Desktop\Debug\Macro Recording System.exe")
apaul
  • 16,092
  • 8
  • 47
  • 82
h_a86
  • 772
  • 6
  • 14
  • 24
  • 2
    How do you know that your exe file is not starting? Since it is windows service your exe file will not appear on your desktop, it will run under system account and you will not see it graphically appear. Is that what confuse you or you are somehow sure it is never starting? – Numenor Jan 08 '12 at 11:27
  • i dont know that exe is started or not – h_a86 Jan 08 '12 at 11:31
  • What does Process Explorer (or Task Manager) show? What activity do you see in Process Monitor? – Richard Jan 08 '12 at 11:36
  • nothing in task manager. – h_a86 Jan 08 '12 at 11:39
  • Right, you can't do this. Change the design of your service. – Cody Gray - on strike Jan 08 '12 at 11:59
  • possible duplicate of [How can I run an EXE program from a Windows Service using C#?](http://stackoverflow.com/questions/5307968/how-can-i-run-an-exe-program-from-a-windows-service-using-c) – Cody Gray - on strike Jan 08 '12 at 11:59

2 Answers2

1

You should add a Logger class to your service, and catch any unhandled exceptions.

You're probably getting an exception when trying to Start() your process.

My guess is that your service is lacking the right permissions to launch that .EXE file

You can try changing the User on which your service runs on (through the control panel, or, through the command line.

Community
  • 1
  • 1
Shai
  • 25,159
  • 9
  • 44
  • 67
0

Windows service doesn't usually have rights to start a new process for security reasons. You will need to grant these rights first.

One of the possible way to do that is log service on as administrator. Right-click on the service in services.msc > Properties > Log On > This account. I am only aware of this method, but it must only work for testing and must never be used in production due to the opened security hole.

oleksii
  • 35,458
  • 16
  • 93
  • 163