按Windows键(像田字的按键)+R键,输入services.msc,回车
qt QtService库源码:
https://github.com/qtproject/qt-solutions/tree/master/qtservice
xxx.exe -i (xxx.exe -install)安装的一个当前用户帐号的服务。
xxx.exe -s 表示启动了这个Service. 此时,在系统的Service查看窗口按F5刷新,可以看到这个服务的运行状态已经变成Running了。
xxx.exe -p (xxx.exe -pause)暂停这个服务
xxx.exe -r (xxx.exe -resume)继续这个服务
xxx.exe -t (xxx.exe -terminate)停止这个服务
xxx.exe -v(xxx.exe -version)
xxx.exe -c (xxx.exe -command )
xxx.exe -h(xxx.exe -help)帮助
xxx.exe -u (xxx.exe -uninstall)卸载这个服务。
xxx.exe -e选项是如普通程序般运行此exe程序,即不以Service来运行,这是为了Debug方便。
httpservice.exe -e 8082 指定监听端口为8082(默认example中是8080)
注意:查看源码可以知道example中只有使用调试模式,就是-e后面才可以加端口号,当使用服务时不能指定端口,因为使用服务时第二第三参数是分别是account, password,
例如:xxx.exe -i admin admin //安装的一个名称为xxx.exe并且用户帐号为admin,密码为admin的服务
其实查看源代码是可以看到以上指令的,源码在QtServiceBase::exec中,源码中没有-s这个指令,但经过测试确实存在此指令,以下为源码帮助打印信息。
-[i|u|e|t|p|r|c|v|h]\n"
"\t-i(nstall) [account] [password]\t: Install the service, optionally using given account and password\n"
"\t-u(ninstall)\t: Uninstall the service.\n"
"\t-e(xec)\t\t: Run as a regular application. Useful for debugging.\n"
"\t-t(erminate)\t: Stop the service.\n"
"\t-p(ause)\t: Pause the service.\n"
"\t-r(esume)\t: Resume a paused service.\n"
"\t-c(ommand) num\t: Send command code num to the service.\n"
"\t-v(ersion)\t: Print version and status information.\n"
"\t-h(elp) \t: Show this help\n"
"\tNo arguments\t: Start the service.\n"
日志记录好像是在:C:\Windows\System32\LogFiles\HTTPERR目录下,还不是很确定。等待验证
参考自: