Batch Script to Install or Uninstall a .NET Windows Service

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

    I did this with an old fashioned batch file....

    Copy the installutil.exe into the same directory as your executable (to make things easier) The following is a generic example of the contents of the batch file necessary: (mine was just names instal.bat)


    installutil MyService.exe 
    sc config MyService type= interact type= own
    sc failure MyService reset= 6000  actions= restart/5000/restart/5000/restart/5000
    sc start MyService 
    

    For more info on command line options for installutil.exe, see here.

    To uninstall the service, use a different batch file with the following contents:


    installutil MyService.exe /u
    

提交回复
热议问题