windows服务安装卸载

@echo off
set filename=E:\WinService\bin\Debug\CiWong.Account.Client.WinService.exe
set servicename=AccountService       //服务名
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 

  卸载:

echo off
set filename=E:\WinService\bin\Debug\CiWong.Account.Client.WinService.exe
set servicename=AccountService
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

  

windows服务安装卸载

上一篇:C#.NET中的CTS、CLS和CLR


下一篇:Windows phone 8.1布局控件