在 Windows 2008 上将 myprogram.exe 作为服务运行时出现问题 [英] Trouble with running myprogram.exe as service on windows 2008

查看:23
本文介绍了在 Windows 2008 上将 myprogram.exe 作为服务运行时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MyProgram.exe 用于侦听来自管道的请求并使用命令提示符其工作正常,但我尝试使用 Windows 服务进行工作但未成功我已尝试在 Windows Server 2008 Enterprise 上执行以下步骤:

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.

参考

所以我在一个博客上读到我们需要为其创建注册表项,然后我尝试了以下步骤

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

我在以下位置找到了我新创建的服务:HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\MyService

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

  1. 从 regedit 的菜单中单击名为 MyService 的键(它看起来像一个文件夹).选择编辑"和新建",然后选择密钥".这将创建一个新的键,您应该将其命名为Parameters".接下来,右键单击您刚刚命名为Parameters"的键并选择new",然后选择string value".将值命名为应用程序".双击字符串值,会弹出一个框.在价值数据"下的框中,您需要输入 Dropbox 的完整路径.在我的例子中,路径是:C:\test\MyProgram.exe\MyProgram.exe

  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

启动您的新服务.导航到控制面板管理工具中的服务列表,或只需在运行框中键入 services.msc.在列表中找到 DropBox 并启动它.新服务应设置为自动启动,但请随时检查以确保.

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.

但是服务启动了几秒钟就被终止了.当我从 services.msc 手动启动服务时,它给出错误

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

启动服务失败 1053:

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.

推荐答案

您不能将任何 EXE 作为 Windows 服务运行.您必须有一个 exe,它了解作为服务的含义并与 Windows 服务控制管理器进行适当的通信.

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.

请参阅 Microsoft 文档,从 http://msdn.microsoft.com/en-us/library/windows/desktop/ms686953(v=vs.85).aspx.

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

这篇关于在 Windows 2008 上将 myprogram.exe 作为服务运行时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆