引用地址:

https://docs.microsoft.com/zh-cn/dotnet/framework/windows-services/how-to-create-windows-services

手动安装你的服务

  1. 在 Windows“启动”菜单或“启动”屏幕上,依次选择“Visual Studio”、“Visual Studio Tools”、“开发人员命令提示”。

    出现 Visual Studio 命令提示。

  2. 访问你的项目的已编译可执行文件所在的目录。

  3. 以你的项目的可执行文件作为参数,通过命令提示运行 InstallUtil.exe:

    installutil <yourproject>.exe  
    

    此工具随 .NET Framework 安装,其路径为 %WINDIR%\Microsoft.NET\Framework[64]\<framework_version>。 

  4. 例如,对于 32 位版本的 .NET Framework 4 或 4.5.*,如果你的 Windows 安装目录为 C:\Windows,则该路径为 C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe

  5. 对于 64 位版本的 .NET Framework 4 或 4.5.*,默认路径为 C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe

 

  也可使用bat文件做启动:

    如果启动service.exe程序为服务

    1. 创建bat文件

    2. 写入以下内容

     C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil  "%cd%"service.exe

    net start service.exe

 

手动卸载你的服务

  1. 在 Windows“启动”菜单或“启动”屏幕上,依次选择“Visual Studio”、“Visual Studio Tools”、“开发人员命令提示”。

    出现 Visual Studio 命令提示。

  2. 以你的项目的输出作为参数,通过命令提示运行 InstallUtil.exe:

    installutil /u <yourproject>.exe  
    
  3. sc delete 从注册表中删除服务的条目。

 

 

更多参考:https://docs.microsoft.com/zh-cn/dotnet/framework/windows-services/how-to-create-windows-services

相关文章:

  • 2022-12-23
猜你喜欢
  • 2022-02-23
  • 2021-10-23
  • 2021-04-15
  • 2019-03-20
  • 2021-11-20
  • 2021-09-18
  • 2021-05-17
相关资源
相似解决方案