Batch Script to Install or Uninstall a .NET Windows Service

后端 未结 10 1658
我在风中等你
我在风中等你 2021-01-31 05:13

I have no experience writing batch scripts, but I was wondering if there was a way to install a .NET Windows service using installutil.exe using such a script, or u

10条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-31 05:42

    This is the batch files I used to install.

    @ECHO OFF
    
    REM The following directory is for .NET 2.0
    set DOTNETFX2=%SystemRoot%\Microsoft.NET\Framework\v2.0.50727
    set PATH=%PATH%;%DOTNETFX2%
    
    echo Installing MyService...
    echo ---------------------------------------------------
    InstallUtil /i MyService.exe
    echo ---------------------------------------------------
    echo Done.
    pause
    

    To Uninstall I used the following:

    @ECHO OFF
    
    REM The following directory is for .NET 2.0
    set DOTNETFX2=%SystemRoot%\Microsoft.NET\Framework\v2.0.50727
    set PATH=%PATH%;%DOTNETFX2%
    
    echo Uninstalling MyService...
    echo ---------------------------------------------------
    InstallUtil /u MyService.exe
    echo ---------------------------------------------------
    echo Done
    

提交回复
热议问题