因为项目的一些变化和原因,需要把数据处理的一个后台程序创建为一个windows服务,运行以下命令能创建成功:

sc create "MyApp Service Name" binPath= "D:/MathxH/Project/SocketS
ervice/trunk/MyApp/Win32/Release/MyApp.exe" start= auto

但是因为我的App程序是非服务(non-service)可执行程序,所以在让它运行的时候,却失败了,抛出以下错误:

error 1053: the service did not respond to the start or control request in a timely fashion

追溯其原因,原来是需要程序,写成一个服务可执行程序才能正确运行。

当然,也有一些工具可以让非服务程序作为windows service来运行,比如NSSM,http://nssm.cc/     它是开源的。由于项目时间原因,本人不想花时间研究它的实现源码了,而且这工具就一个exe,没其他冗余的依赖bin。所以直接可以与项目exe捆绑在一起,作为安装时的一个辅助工具。

该工具基本的命令行:

nssm install "Service Name" "exe file path"

nssm remove "Service Name"

nssm start "Service Name"
nssm stop "Service Name"
nssm restart "Service Name"

references:
https://msdn.microsoft.com/en-us/library/40xe80wx(v=vs.80).aspx

http://stackoverflow.com/questions/3582108/create-windows-service-from-executable

https://code.msdn.microsoft.com/windowsapps/CppWindowsService-cacf4948/sourcecode?fileId=21604&pathId=2141735795

最新文章

  1. Asp.Net Core 项目实战之权限管理系统(7) 组织机构、角色、用户权限
  2. Android模拟器Genymotion如何访问本地服务器?
  3. HDU 5015 233 Matrix --矩阵快速幂
  4. Winform快速开发组件的实现(二)
  5. php输出函数 var_dump, dump,print,print_r 区别
  6. CSS快速制作图片轮播的焦点
  7. 转:windows xp下如何安装SQL server2000企业版
  8. cmd编译运行Java文件详解
  9. Web数据采集
  10. 按钮的图标 Button icons-JQUERY MOBILE 1.0正式版中文手册
  11. jira + confluence 安装和破解
  12. R语言-来自拍拍贷的数据探索
  13. #194 sequence(搜索+动态规划+主席树)
  14. sourceInsight工具移除不掉项目 source Insight Add and Remove Project Files
  15. opencv的DMatch
  16. 一条SQL语句中算日销售额和月销售额
  17. OpenLDAP备份和恢复
  18. 阿里与ShopRunner达成协议 联手在国内推出服务
  19. [spring]Bean注入——在XML中配置
  20. 多线程-CAS原理

热门文章

  1. 对于AttributeError: 'Flask' object has no attribute 'cli'的解决办法
  2. 多态 JAVA
  3. SKScene类
  4. hash表的创建
  5. css09浮动属性
  6. 8、第八次课jquery第一节20151006
  7. 文本溢出、垂直外边距合并、BFC、hasLayout
  8. Examples_08_07
  9. Qt 数据库创建表失败原因之数据库关键字
  10. EcStore操作笔记