Trouble with running myprogram.exe as service on windows 2008

℡╲_俬逩灬. 提交于 2019-12-12 12:29:04

问题


The MyProgram.exe is made to listen the request from pipe and using command prompt its working perfect but I tried to work it by using windows service but not success I have tried following steps on windows server 2008 enterprise:

> sc create MyService binPath= "C:\test\MyProgram.exe" DisplayName= "MyProgramService"
>[SC] CreateService SUCCESS

>sc start MyService 
[SC] StartService FAILED 1053:

The service did not respond to the start or control request in a timely fashion.

reference

So I read on one blog that we need to create registry entry for the same then I tried the following steps

I found my newly created service under: HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\MyService

  1. Click the key named MyService (it looks like a folder) from the menu in regedit. Select “edit” and “new” and then select “key.” This will create a new key which you should name “Parameters.” Next, right- click on the key that you just named “Parameters” and select “new” and then “string value.” Name the value “Application.” Double-click the string value and a box will pop up. In the box under “value data”, you need to put the full path to the Dropbox. In my case, the path was: C:\test\MyProgram.exe\MyProgram.exe

  2. Start your new service. Navigate to the services list in the control panel‘s administrative tools or simply type services.msc in the run box. Find DropBox in the list and start it. New services should be set to start automatically, but feel free to check it to be sure.

But the service start for a few seconds and get terminated. When I start manually service from services.msc it give error

StartService FAILED 1053:

The service did not respond to the start or control request in a timely fashion.

Not sure why any one have work on it, please guidance to make it as service.


回答1:


You can't run just any EXE as a Windows service. You must have an exe which understands what it means to be a service and which communicates appropriately with the Windows Service Control Manager.

Refer to the Microsoft documentation, starting with http://msdn.microsoft.com/en-us/library/windows/desktop/ms686953(v=vs.85).aspx.



来源:https://stackoverflow.com/questions/12560727/trouble-with-running-myprogram-exe-as-service-on-windows-2008

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!