How to use “sc” to install a service and specify NO ACTION for “subsequent failures” under recovery

前端 未结 2 1441
名媛妹妹
名媛妹妹 2021-02-19 06:12

I created a service in VB.NET and wanted to use the \"sc\" program to install it. (I needed to package it so that someone else in my organization could perform the actual instal

2条回答
  •  失恋的感觉
    2021-02-19 06:39

    To expand on this answer, the sc command is stupidly finnicky, and you need to do a couple things:

    1. you must provide 'reset' and 'actions' at the same time
    2. you must have a space after each option, so reset= , etc
    3. you cannot provide no options to 'action' (despite what the documentation on sc.exe claims), but you can provide empty values separated by a slash. All of these 3 commands will make it so there are no actions for any of the 3 attempts
      • sc failure EraAgentSvc reset= 86400 actions= //
      • sc failure EraAgentSvc reset= 86400 actions= ////
      • sc failure EraAgentSvc reset= 86400 actions= //////

    and those commands will end up with the result from 'sc qfailure':

    C:\Users\Administrator>sc qfailure EraAgentSvc
    [SC] QueryServiceConfig2 SUCCESSSERVICE_NAME: EraAgentSvc
            RESET_PERIOD (in seconds)    : 86400
            REBOOT_MESSAGE               :
            COMMAND_LINE                 :
    

提交回复
热议问题