exe程序注册服务bat脚本

exe注册为window服务,首先exe程序包含服务启动运行的接口;
void WINAPI service_main(int argc, char** argv);
void WINAPI ServiceHandler(unsigned long fdwControl);
没有这些接口,即使注册为服务,也无法启动程序。
接口如何实现找百度,网上资料很多

注册服务:

@echo off
SET ServerName=coderserver
SET ServerExeFile=%ServerName%.exe
sc create %ServerName% binPath= "%~dp0%ServerExeFile%" start= auto
sc config %ServerName% type= interact type= own
echo "%~dp0%ServerExeFile%"
pause

删除服务

@echo off
SET ServerName=coderserver
sc delete %ServerName%
pause

你可能感兴趣的:(c++)