none
Windows service didn't autostart when I reboot machine RRS feed

  • Question

  • I created 4 windows services using .Net 4.0. Say: Service1~4.

    Service1 and 2 are standalone services. Service3 and 4 are both depend on Service1.
    All of them running under same user account. I used installutil.exe to install them onto a Windows2003 (ver 5.2.3790) machine.

    When I reboot the machine, only Service1 and 2 are up. Service3 and 4 are not, although their "Startup Type" says "Automatic". There's no entry in event log related to these 2 services. No local application log written, it's like they've never try to start up.

    After computer boot up, I can manually start Service3 and 4, they will run without problem.
    If I manually stop Service1, dialog pops up to warn me: "If Service1 stopped, Service 3 and 4 will also stop". So I guess I set service dependency  on Service 3 and 4 correct.

    Here comes the itch point: if I remove the dependency to Service1, Service 3 and 4 started automatically after reboot. I don't know what went wrong, any idea will be appreciated!

    Monday, January 31, 2011 9:00 AM

Answers

  • Correct. It's really hard to know the order in services start. In that case, you may choose to create a batch file to start services individually and put the batch file in startup. Your batch file may look like,

    SC START Service1
    SC START Service3
    SC START Service4
    

    Then, add the batch file location to following registry.

    HKLM\Software\Microsoft\Windows\CurrentVersion\Run

    Try this.

     


    Please mark this post as answer if it solved your problem. Happy Programming !!!
    • Marked as answer by Leishen Wednesday, February 9, 2011 6:51 AM
    Wednesday, February 9, 2011 3:40 AM

All replies

  • Check the order in which Service1-Service4 are started. If service3 and Service4 are set to start before Service1 then, they will not start.

    Hope this helps.

    --------------------------------

    Please mark the post answered if it solved your problem. Happy Programming !!!

    Monday, January 31, 2011 3:47 PM
  • How can I check it, in services.msc?
    Tuesday, February 1, 2011 2:40 AM
  • Open Regedit and goto HKLM\System\CurrentControlSet\Services.

    1. Under services you should see Service1, Service3 and Service4 keys. click on Service3, on the right-hand pane, you should see "DependOnService" whose value is "Service1". If not create a new key "DependOnService" of type REG_MULTI_SZ with value "Service1". Do the same thing for Service4 as well

    2. Now set the startup type of Service3 & Service4 to "Automatic (Delayed)"

    • Proposed as answer by Shishir DK Wednesday, February 2, 2011 6:03 AM
    • Marked as answer by eryang Monday, February 7, 2011 2:49 AM
    • Unmarked as answer by Leishen Wednesday, February 9, 2011 2:26 AM
    Tuesday, February 1, 2011 8:46 AM
  • I did what you said, but it still not work.

    The strange thing to me is: there's nothing in event log about Service3 and 4. It gives me the feeling that they never try to start up.

    Wednesday, February 9, 2011 2:33 AM
  • Correct. It's really hard to know the order in services start. In that case, you may choose to create a batch file to start services individually and put the batch file in startup. Your batch file may look like,

    SC START Service1
    SC START Service3
    SC START Service4
    

    Then, add the batch file location to following registry.

    HKLM\Software\Microsoft\Windows\CurrentVersion\Run

    Try this.

     


    Please mark this post as answer if it solved your problem. Happy Programming !!!
    • Marked as answer by Leishen Wednesday, February 9, 2011 6:51 AM
    Wednesday, February 9, 2011 3:40 AM
  • Hi Adavesh,

    Thank you for the reply. I think this might be a good alternative.

    However, I still want to know what happened to the "standard" approach... :(

    Wednesday, February 9, 2011 6:51 AM