1. 添加 Windows Service 项目

[WCF] - 使用 bat 批处理文件将 WCF 服务部署为 Windows Service

2. 添加 WCF 项目引用

[WCF] - 使用 bat 批处理文件将 WCF 服务部署为 Windows Service

3. 更新 App.config 配置文件(可以从 WCF的 Web.config 拷贝过来),设置服务地址。

[WCF] - 使用 bat 批处理文件将 WCF 服务部署为 Windows Service

4. 配置 ServiceInstaller,ProcessInstaller。

[WCF] - 使用 bat 批处理文件将 WCF 服务部署为 Windows Service

[WCF] - 使用 bat 批处理文件将 WCF 服务部署为 Windows Service

5. 配置 bat 批处理文件

Install.bat 安装服务

@echo off
if "%PROCESSOR_ARCHITECTURE%"=="x86" goto x86
if "%PROCESSOR_ARCHITECTURE%"=="AMD64" goto x64
exit

:x86
copy C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe InstallUtil.exe /Y
installutil.exe WindowsService.exe
Net Start ServiceHost
sc config ServiceHost start= auto
pause
exit

:x64
copy C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe InstallUtil.exe /Y
installutil.exe WindowsService.exe
Net Start ServiceHost
sc config ServiceHost start= auto
pause
exit

Uninstall.bat 卸载服务

@echo off
if "%PROCESSOR_ARCHITECTURE%"=="x86" goto x86
if "%PROCESSOR_ARCHITECTURE%"=="AMD64" goto x64
exit

:x86
copy C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe InstallUtil.exe /Y
installutil.exe /u WindowsService.exe
pause
exit

:x64
copy C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe InstallUtil.exe /Y
installutil.exe /u WindowsService.exe
pause
exit

 

文章来源
http://www.cnblogs.com/jinzesudawei/p/7812235.html

相关文章:

  • 2022-01-25
  • 2021-10-17
  • 2021-12-01
  • 2021-07-18
  • 2021-09-23
  • 2022-02-21
猜你喜欢
  • 2021-05-22
  • 2021-07-10
  • 2022-12-23
  • 2021-08-07
  • 2022-02-01
  • 2021-12-11
  • 2022-12-23
相关资源
相似解决方案