How to make a .NET Windows Service start right after the installation?

前端 未结 8 1498
再見小時候
再見小時候 2020-11-22 10:49

Besides the service.StartType = ServiceStartMode.Automatic my service does not start after installation

Solution

Inserted this code on my Pr

8条回答
  •  攒了一身酷
    2020-11-22 11:38

    The easiest solution is found here install-windows-service-without-installutil-exe by @Hoàng Long

    @echo OFF
    echo Stopping old service version...
    net stop "[YOUR SERVICE NAME]"
    echo Uninstalling old service version...
    sc delete "[YOUR SERVICE NAME]"
    
    echo Installing service...
    rem DO NOT remove the space after "binpath="!
    sc create "[YOUR SERVICE NAME]" binpath= "[PATH_TO_YOUR_SERVICE_EXE]" start= auto
    echo Starting server complete
    pause
    

提交回复
热议问题