sc配置windows服务

需要的nuget包

  • Microsoft.Extensions.Hosting.WindowsServices 用于windows服务
  • Microsoft.Extensions.Hosting.Systemd 用于linux守护程序

DotnetPublish发布程序

  • 帮助

    dotnet publish --help
    
  • 注意RID

  • 示例

    dotnet publish -c Release -r win8-x64 -o C:\MyWebs\test
    

SC命令部署windows服务程序

  • 帮助

    sc.exe
    
  • 创建和启动

    sc.exe create 名字 binPath= "路径"
    sc.exe start 名字
    
  • 自动启动和描述

    sc.exe config 名字 start= auto
    sc.exe description 名字 描述
    
  • 查询服务状态

    sc.exe query 名字
    
  • 停用和删除

    sc.exe stop 名字 
    sc.exe delete 名字
    
posted @ 2020-09-01 11:54  扬扬S  阅读(309)  评论(0)    收藏  举报