Batch Script to Install or Uninstall a .NET Windows Service

后端 未结 10 1582
我在风中等你
我在风中等你 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:40

    This is the one I use. I found it and use it. Thanx to the creator..

    @echo off
    
    SET PROG="YourServiceHere.exe"
    SET FIRSTPART=%WINDIR%"\Microsoft.NET\Framework\v"
    SET SECONDPART="\InstallUtil.exe"
    SET DOTNETVER=2.0.50727
      IF EXIST %FIRSTPART%%DOTNETVER%%SECONDPART% GOTO install
    SET DOTNETVER=1.1.4322
      IF EXIST %FIRSTPART%%DOTNETVER%%SECONDPART% GOTO install
    SET DOTNETVER=1.0.3705
      IF EXIST %FIRSTPART%%DOTNETVER%%SECONDPART% GOTO install
    GOTO fail
    :install
      ECHO Found .NET Framework version %DOTNETVER%
      ECHO Installing service %PROG%
      %FIRSTPART%%DOTNETVER%%SECONDPART% %PROG%
      GOTO end
    :fail
      echo FAILURE -- Could not find .NET Framework install
    :param_error
      echo USAGE: installNETservie.bat [install type (I or U)] [application (.exe)]
    :end
      ECHO DONE!!!
      Pause
    

提交回复
热议问题