将以下文字复制到txt文件中,更改后缀名为.bat,将此.bat文件放在服务的同级目录下。
1.安装服务:
@echo off
set filename=AIIMSService.exe
set servicename=AIIMSTaskTimer
pause
echo ============================操作日志==================================== >InstallService.log
if exist "%SystemRoot%\Microsoft.NET\Framework\v4.0.30319" goto netOld
:DispError
echo 您的机器上没有安装 .net Framework 4.0,安装即将终止
echo 您的机器上没有安装 .net Framework 4.0,安装即将终止 >>InstallService.log
goto LastEnd
:netOld
cd %SystemRoot%\Microsoft.NET\Framework\v4.0.30319
echo 您的机器上安装了相应的.net Framework 4.0,可以安装本服务.
echo 您的机器上安装了相应的.net Framework 4.0,可以安装本服务 >>InstallService.log
echo off
echo 清理原有服务项. . .
%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\installutil /U %filename% >> InstallService.log
echo 清理完毕
echo.
echo *********************
echo 安装服务
%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\installutil %filename% >> InstallService.log
echo 启动服务
net start %servicename% >> InstallService.log
echo *********************
echo ======================================================================= >>InstallService.log
type InstallService.log
echo.
echo 操作结束,可以查看日志文件InstallService.log 中具体的操作结果。
:LastEnd
pause
rem exit
2.卸载服务
echo off
set filename=AIIMSService.exe
set servicename=AIIMSTaskTimer
echo ============================操作日志==================================== >UnInstallService.log
if exist "%SystemRoot%\Microsoft.NET\Framework\v4.0.30319" goto netOld
:DispError
echo 您的机器上没有安装.net FrameWork 4.0,卸载即将终止
echo 您的机器上没有安装.net FrameWork 4.0,卸载即将终止 >>UnInstallService.log
pause
goto LastEnd
:netOld
echo 即将卸载本服务…
echo off
pause
echo *********************
echo 停止服务
net stop %servicename% >>UnInstallService.log
cd %SystemRoot%\Microsoft.NET\Framework\v4.0.30319
%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\installutil /uninstall %filename% >>UnInstallService.log
echo 卸载服务
echo ======================================================================= >>UnInstallService.log
echo *********************
type UnInstallService.log
echo.
echo 操作结束,可以查看日志文件UnInstallService.log中具体的操作结果。
:LastEnd
pause
rem exit