{"id":10227,"date":"2021-07-19T00:13:36","date_gmt":"2021-07-19T07:13:36","guid":{"rendered":"https:\/\/www.coretechnologies.com\/blog\/?p=10227"},"modified":"2022-02-21T21:50:58","modified_gmt":"2022-02-22T05:50:58","slug":"delay-service-start","status":"publish","type":"post","link":"https:\/\/www.coretechnologies.com\/blog\/windows-services\/delay-service-start\/","title":{"rendered":"Q&#038;A: How Do I Delay the Start of my Windows Service?"},"content":{"rendered":"<div align=\"center\"><img loading=\"lazy\" decoding=\"async\" class=\"no-lazy-load\" src=\"\/blog\/images\/qa-delay-windows-service-start.webp\" style=\"margin-bottom:20px;\" title=\"How Do I Delay the Start of my Windows Service?\" alt=\"How Do I Delay the Start of my Windows Service?\" border=\"0\" width=\"380\" height=\"160\"><\/div>\n<div class=\"blog-qa-question-box\">\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/cdn.coretechnologies.com\/images\/quotes-transparent-21x21.png\" width=\"21\" height=\"21\">&nbsp;&nbsp;Our build server has a ton of services installed and it takes a while for them to start whenever the machine boots. One of the services doesn&#8217;t connect to the database if it starts too soon. When that happens, I have to log in and start it manually. Is there a way to delay the service until the other services are up and running?<\/p>\n<p align=\"right\">&mdash; Christos D.<\/p>\n<\/div>\n<p>Hi Christos.<\/p>\n<p>After some brainstorming, our team has come up with four potential solutions for you.<\/p>\n<h2 class=\"blog-caption\">Solution #1: Set your Service to &#8220;Automatic (Delayed Start)&#8221;<\/h2>\n<p>The simplest way to delay a service is to adjust when it starts at boot. Instead of starting as soon as possible, you can tell Windows to launch the service about 2 (or more) minutes after boot.<\/p>\n<p>To make that change:<\/p>\n<ol>\n<li>\n<p>Start the Services utility.<\/p>\n<p>To do so, press the <b>Windows + R<\/b> keys to open the <b>Run<\/b> window, and then type <b>services.msc<\/b>.<\/p>\n<\/li>\n<li>\n<p>Find your service in the list. Double-click its row to open the service&#8217;s properties.<\/p>\n<\/li>\n<li>\n<p>In the <b>Startup type<\/b> field, select <b>Automatic (Delayed Start)<\/b> from the list:<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/choose-automatic-delayed-start.png\" class=\"zoomPopup\" title=\"Choose Automatic (Delayed Start)\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/choose-automatic-delayed-start.png\" title=\"Choose Automatic (Delayed Start) (click to enlarge)\" alt=\"Choose Automatic (Delayed Start)\" border=\"0\" \/><\/a><\/div>\n<\/li>\n<li>\n<p>Click OK to save your change.<\/p>\n<\/li>\n<\/ol>\n<h3 class=\"blog-caption\">Need to wait for longer than 2 minutes?<\/h3>\n<p>By default, all &#8220;delayed start&#8221; services are launched a couple of minutes after boot. Fortunately, that <a href=\"\/WindowsServices\/FAQ.html#SetDelayedStartTime\">wait time is configurable<\/a> and you can set it to longer if you like, but that setting applies to <b>all delayed start services<\/b>. There is simply no way to adjust the wait time of a single delayed start service.<\/p>\n<h2 class=\"blog-caption\">Solution #2: Specify a Dependency between Services<\/h2>\n<p>Another option for delaying the start of a service is to mark it as dependent on another service.<\/p>\n<p>To explain, let&#8217;s take two services, Service1 and Service2. If Service1 must start before Service2, you would update Service2 to add Service1 as a dependent. You would say that Service2 depends on Service1.<\/p>\n<p>I know that may be a bit confusing, so let&#8217;s look at a real-world example. <\/p>\n<p>Microsoft&#8217;s &#8220;System Events Broker&#8221; depends on a couple of services: &#8220;Remote Procedure Call (RPC)&#8221; and &#8220;RPC Endpoint Mapper&#8221;. You can see the relationship in the service&#8217;s properties (in the <a href=\"\/blog\/windows-services\/essential-tools-windows-services-msc\/\">Services<\/a> application):<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/systemeventsbroker-service-dependencies.png\" class=\"zoomPopup\" title=\"System Events Broker service: Dependencies\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/systemeventsbroker-service-dependencies.png\" title=\"System Events Broker service: Dependencies (click to enlarge)\" alt=\"System Events Broker service: Dependencies\" border=\"0\" \/><\/a><\/div>\n<p>Because of those dependencies, Windows will always start the two RPC services before launching the &#8220;System Events Broker&#8221; service.<\/p>\n<p>So to delay the start of your important service, <a href=\"\/WindowsServices\/FAQ.html#AddADependency\">mark it as dependent on another, precursor service<\/a>.<\/p>\n<p>Note however, there are significant side effects of setting up a dependency relationship between two services.<\/p>\n<p>For example, the screenshot above also shows that &#8220;Task Scheduler&#8221; depends on &#8220;System Events Broker&#8221;. As a result of that relationship, <b>stopping &#8220;System Events Broker&#8221; will stop &#8220;Task Scheduler&#8221;<\/b>, as the Services application informs us here:<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/stop-systemeventsbroker-service.png\" class=\"zoomPopup\" title=\"Stop the System Events Broker service\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/stop-systemeventsbroker-service.png\" title=\"Stop the System Events Broker service (click to enlarge)\" alt=\"Stop the System Events Broker service\" border=\"0\" \/><\/a><\/div>\n<p>You see, the dependency relationship is about much more startup sequence. It implies that &#8220;System Events Broker&#8221; is critical for &#8220;Task Scheduler&#8221; to operate.<\/p>\n<p>So if you mark your service as dependent on another service, stopping that other service might stop your own. Make sure you&#8217;re OK with that.<\/p>\n<h2 class=\"blog-caption\">Solution #3: Launch your service from an &#8220;at startup&#8221; scheduled task<\/h2>\n<p>Instead of having the Windows Services launch your service, you can shift that responsibility to the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Windows_Task_Scheduler\" target=\"_blank\" rel=\"noopener\">Windows Task Scheduler<\/a>. And in doing so, you can introduce a post-boot delay to start the service after your machine settles down.<\/p>\n<p>Here&#8217;s how to create a scheduled task that starts your service a few minutes after boot:<\/p>\n<ol>\n<li>\n<p>Launch the Task Scheduler.<\/p>\n<p>To do so, press the <b>Windows + R<\/b> keys to open the <b>Run<\/b> window, and then type <b>taskschd.msc<\/b>.<\/p>\n<\/li>\n<li>\n<p>On the right, click <b>Create Basic Task<\/b> to launch the wizard:<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/task-scheduler-create-basic-task-win-10.png\" class=\"zoomPopup\" title=\"Task Scheduler: Create Basic Task\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/task-scheduler-create-basic-task-win-10.png\" title=\"Task Scheduler: Create Basic Task (click to enlarge)\" alt=\"Task Scheduler: Create Basic Task\" border=\"0\" width=\"520\" \/><\/a><\/div>\n<\/li>\n<li>\n<p>Give your task a meaningful name. For example, we&#8217;re restarting the Print Spooler service 10 minutes after boot:<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/start-spooler-service-task-name.png\" class=\"zoomPopup\" title=\"Start Spooler service task: Name\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/start-spooler-service-task-name.png\" title=\"Start Spooler service task: Name (click to enlarge)\" alt=\"Start Spooler service task: Name\" border=\"0\" width=\"520\" \/><\/a><\/div>\n<p>Click <b>Next<\/b>.<\/p>\n<\/li>\n<li>\n<p>For the trigger, choose <b>When the computer starts<\/b>:<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/start-spooler-service-task-trigger.png\" class=\"zoomPopup\" title=\"Start Spooler service task: Trigger\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/start-spooler-service-task-trigger.png\" title=\"Start Spooler service task: Trigger (click to enlarge)\" alt=\"Start Spooler service task: Trigger\" border=\"0\" width=\"520\" \/><\/a><\/div>\n<p>Click <b>Next<\/b>.<\/p>\n<\/li>\n<li>\n<p>For action, select <b>Start a program<\/b>:<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/start-spooler-service-task-action.png\" class=\"zoomPopup\" title=\"Start Spooler service task: Action\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/start-spooler-service-task-action.png\" title=\"Start Spooler service task: Action (click to enlarge)\" alt=\"Start Spooler service task: Action\" border=\"0\" width=\"520\" \/><\/a><\/div>\n<p>Click <b>Next<\/b>.<\/p>\n<\/li>\n<li>\n<p>In the <b>Program\/script<\/b> field, enter <b>NET.EXE<\/b>.<\/p>\n<p>And in the <b>Add arguments<\/b> field, enter <b>START<\/b> followed by the <a href=\"\/WindowsServices\/FAQ.html#FindServiceName\">name of your service<\/a>:<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/start-spooler-service-task-program.png\" class=\"zoomPopup\" title=\"Start Spooler service task: Run NET START\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/start-spooler-service-task-program.png\" title=\"Start Spooler service task: Run NET START (click to enlarge)\" alt=\"Start Spooler service task: Run NET START\" border=\"0\" width=\"520\" \/><\/a><\/div>\n<p>Click <b>Next<\/b>.<\/p>\n<\/li>\n<li>\n<p>On the summary screen, check the <b>Open the Properties dialog&#8230;<\/b> box. We still need to make a few adjustments to the new scheduled task:<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/start-spooler-service-task-summary.png\" class=\"zoomPopup\" title=\"Start Spooler service task: Summary\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/start-spooler-service-task-summary.png\" title=\"Start Spooler service task: Summary (click to enlarge)\" alt=\"Start Spooler service task: Summary\" border=\"0\" width=\"520\" \/><\/a><\/div>\n<p>Click <b>Finish<\/b> to exit the wizard.<\/p>\n<\/li>\n<li>\n<p>In the Properties window that comes up, affirm a couple of options:<\/p>\n<p><b>Run whether user is logged on or not<\/b>. Otherwise, your service will only restart when you&#8217;re logged on.<\/p>\n<p><b>Run with highest privileges<\/b>. Necessary because starting your service likely requires administrative rights.<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/start-spooler-service-task-properties.png\" class=\"zoomPopup\" title=\"Start Spooler service task: Properties\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/start-spooler-service-task-properties.png\" title=\"Start Spooler service task: Properties (click to enlarge)\" alt=\"Start Spooler service task: Properties\" border=\"0\" width=\"520\" \/><\/a><\/div>\n<\/li>\n<li>\n<p>Switch to the <b>Triggers<\/b> tab and edit the <b>At startup<\/b> trigger.<\/p>\n<p>In the <b>Edit Trigger<\/b> window, check the <b>Delay task for<\/b> box and enter your delay in minutes. You may have to type the time as not all values appear in the dropdown:<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/start-spooler-service-task-edit-trigger.png\" class=\"zoomPopup\" title=\"Start Spooler service task: Edit Trigger\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/start-spooler-service-task-edit-trigger.png\" title=\"Start Spooler service task: Edit Trigger (click to enlarge)\" alt=\"Start Spooler service task: Edit Trigger\" border=\"0\" width=\"520\" \/><\/a><\/div>\n<p>Click <b>OK<\/b> to save your change.<\/p>\n<\/li>\n<li>\n<p>Back on the Properties window, click <b>OK<\/b> to close out of the task. You will probably have to enter your password:<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/start-spooler-service-task-enter-password.png\" class=\"zoomPopup\" title=\"Start Spooler service task: Enter password\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/start-spooler-service-task-enter-password.png\" title=\"Start Spooler service task: Enter password (click to enlarge)\" alt=\"Start Spooler service task: Enter password\" border=\"0\" width=\"520\" \/><\/a><\/div>\n<\/li>\n<\/ol>\n<p>And now that you have a scheduled task to start the service when you want, you should prevent the service from trying to start automatically at boot. Open your service&#8217;s properties and change the <b>Startup type<\/b> to <b>Manual<\/b>:<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/set-service-startup-type-manual.png\" class=\"zoomPopup\" title=\"Set service startup type to Manual\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/set-service-startup-type-manual.png\" title=\"Set service startup type to Manual (click to enlarge)\" alt=\"Set service startup type to Manual\" border=\"0\" \/><\/a><\/div>\n<p>Finally, please reboot and make sure that your service starts in the expected time frame.<\/p>\n<h2 class=\"blog-caption\">Solution #4 (for AlwaysUp services only): Pause before starting<\/h2>\n<p>If your service was created by AlwaysUp, you are able to stall your application via a configuration setting.<\/p>\n<p>To do so:<\/p>\n<ol>\n<li>\n<p>Edit your application in AlwaysUp.<\/p>\n<\/li>\n<li>\n<p>Switch to the <b>Startup<\/b> tab.<\/p>\n<\/li>\n<li>\n<p>In the <b>Pause for<\/b> field, enter a suitable delay in seconds:<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/alwaysup-set-startup-pause.png\" class=\"zoomPopup\" title=\"Set AlwaysUp startup pause time\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/alwaysup-set-startup-pause.png\" title=\"Set AlwaysUp startup pause time (click to enlarge)\" alt=\"Set AlwaysUp startup pause time\" border=\"0\" \/><\/a><\/div>\n<\/li>\n<li>\n<p>Check the <b>But only after a reboot<\/b> box &mdash; to avoid the pause when you start the service\/application manually.<\/p>\n<\/li>\n<li>\n<p>Click <b>OK<\/b> to save your settings.<\/p>\n<\/li>\n<\/ol>\n<p>The next time your computer boots, Windows will start the AlwaysUp service. And, as you instructed, AlwaysUp will pause for a while before launching your application.<\/p>\n<p style=\"margin-top:30px;\">\nHopefully one of these methods will work in your situation!<\/p>\n<!-- relpost-thumb-wrapper --><div class=\"relpost-thumb-wrapper\"><!-- filter-class --><div class=\"relpost-thumb-container\"><style>.relpost-block-single-image, .relpost-post-image { margin-bottom: 10px; }<\/style><h3>You may also like...<\/h3><div style=\"clear: both\"><\/div><div style=\"clear: both\"><\/div><!-- relpost-block-container --><div class=\"relpost-block-container relpost-block-column-layout\" style=\"--relposth-columns: 3;--relposth-columns_t: 2; --relposth-columns_m: 2\"><a href=\"https:\/\/www.coretechnologies.com\/blog\/alwaysup\/survive-automatic-updates\/\"class=\"relpost-block-single\" ><div class=\"relpost-custom-block-single\"><img decoding=\"async\" loading=\"lazy\" class=\"relpost-block-single-image\" alt=\"How to Survive Automatic Updates when Running 24\/7 with AlwaysUp\"  src=\"https:\/\/www.coretechnologies.com\/blog\/wp-content\/uploads\/auto-update-150x150-1.png\" style=\"aspect-ratio:1\/1\" style=\"aspect-ratio:1\/1\"><\/img><div class=\"relpost-block-single-text\"  style=\"height: 75px;font-family: Arial;  font-size: 12px;  color: #333333;\"><h2 class=\"relpost_card_title\">How to Survive Automatic Updates when Running 24\/7 with AlwaysUp<\/h2><\/div><\/div><\/a><a href=\"https:\/\/www.coretechnologies.com\/blog\/windows-services\/restart-remote-service\/\"class=\"relpost-block-single\" ><div class=\"relpost-custom-block-single\"><img decoding=\"async\" loading=\"lazy\" class=\"relpost-block-single-image\" alt=\"Q&amp;A: How do I Restart a Windows Service on a Remote Computer?\"  src=\"https:\/\/www.coretechnologies.com\/blog\/wp-content\/uploads\/restart-remote-service-150x150-1.png\" style=\"aspect-ratio:1\/1\" style=\"aspect-ratio:1\/1\"><\/img><div class=\"relpost-block-single-text\"  style=\"height: 75px;font-family: Arial;  font-size: 12px;  color: #333333;\"><h2 class=\"relpost_card_title\">Q&amp;A: How do I Restart a Windows Service on a Remote Computer?<\/h2><\/div><\/div><\/a><a href=\"https:\/\/www.coretechnologies.com\/blog\/alwaysup\/multiple-automatic-logons\/\"class=\"relpost-block-single\" ><div class=\"relpost-custom-block-single\"><img decoding=\"async\" loading=\"lazy\" class=\"relpost-block-single-image\" alt=\"Q&amp;A: Does AlwaysUp Support Multiple Automatic Logons?\"  src=\"https:\/\/www.coretechnologies.com\/blog\/wp-content\/uploads\/multiple-autologon-services.webp\" style=\"aspect-ratio:1\/1\" style=\"aspect-ratio:1\/1\"><\/img><div class=\"relpost-block-single-text\"  style=\"height: 75px;font-family: Arial;  font-size: 12px;  color: #333333;\"><h2 class=\"relpost_card_title\">Q&amp;A: Does AlwaysUp Support Multiple Automatic Logons?<\/h2><\/div><\/div><\/a><\/div><!-- close relpost-block-container --><div style=\"clear: both\"><\/div><\/div><!-- close filter class --><\/div><!-- close relpost-thumb-wrapper -->","protected":false},"excerpt":{"rendered":"<p>&nbsp;&nbsp;Our build server has a ton of services installed and it takes a while for them to start whenever the machine boots. One of the services doesn&#8217;t connect to the database if it starts too soon. When that happens, I &hellip; <a href=\"https:\/\/www.coretechnologies.com\/blog\/windows-services\/delay-service-start\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":10414,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[26,37,127,144,164,196],"class_list":["post-10227","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-windows-services","tag-alwaysup-tag","tag-automatic-delayed","tag-qa","tag-service-dependencies","tag-task-scheduler","tag-windows-services-2"],"_links":{"self":[{"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/10227","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/comments?post=10227"}],"version-history":[{"count":14,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/10227\/revisions"}],"predecessor-version":[{"id":10945,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/10227\/revisions\/10945"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/media\/10414"}],"wp:attachment":[{"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/media?parent=10227"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/categories?post=10227"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/tags?post=10227"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}