一般我们使用的工具都有自己注册服务的方法,如我们公司产品oKit用到的四个家伙:
MySQL
注册:
${MySQLinstallpath}\bin\mysqld.exe --install ${MySQLServerName}
卸载:
${MySQLinstallpath}\bin\mysqld.exe /remove ${MySQLServerName}
Apache
注册:
${ApacheInstallPath}\bin\httpd.exe -n ${ApacheServerName} -k install
卸载:
${ApacheInstallPath}\bin\httpd.exe -n ${ApacheServerName} -k uninstall
Tomcat
注册:
${TomcatInstallPath}\bin\service.bat install ${TomcatServerName}
卸载:
${TomcatInstallPath}\bin\service.bat remove ${TomcatServerName}
Openfire
注册:
${OpenfireInstallPath}\bin\openfire-service /install ${OpenfireServerName}
卸载:
${OpenfireInstallPath}\bin\openfire-service /uninstall ${OpenfireServerName}
此外呢,可能还有一些没有提供这种命令,我们可以用Windows的一个非常实用的命令来完成这项工作——sc
通用的服务操作命令sc
注册:
sc create ${ServerName} binPath= "${exeinstallpath}" start= auto
卸载:
sc delete ${ServerName}
关于这个命令可以参见这篇博客
然后呢,关于启动停止服务,除了万能的sc之外,还可以用net命令
启动停止服务net
启动:
net start ${ServerName}
停止:
net stop ${ServerName}