{"id":8739,"date":"2020-05-01T19:14:29","date_gmt":"2020-05-02T02:14:29","guid":{"rendered":"https:\/\/www.coretechnologies.com\/blog\/?p=8739"},"modified":"2022-09-04T00:42:50","modified_gmt":"2022-09-04T07:42:50","slug":"how-to-restart-at-specific-time","status":"publish","type":"post","link":"https:\/\/www.coretechnologies.com\/blog\/windows-services\/how-to-restart-at-specific-time\/","title":{"rendered":"Q&#038;A: How do I Restart my Windows Service at a Specific Time every Week?"},"content":{"rendered":"<div align=\"center\"><img loading=\"lazy\" decoding=\"async\" class=\"no-lazy-load\" src=\"\/blog\/images\/restart-service-specific-time.webp\" title=\"Restart Windows Service at a Specific Time\" alt=\"Restart Windows Service at a Specific Time\" border=\"0\" width=\"380\" height=\"154\"><\/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;I want to restart some specific service for a specific time every week. Can I use the NET command?<\/p>\n<p align=\"right\">&mdash; Shanmuga<\/p>\n<\/div>\n<p>Hi Shanmuga.<\/p>\n<p>Yes. With the help of the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Windows_Task_Scheduler\" target=\"_blank\" rel=\"noopener noreferrer\">Windows Task Scheduler<\/a>, you can use the <a href=\"\/blog\/windows-services\/essential-tools-for-windows-services-net-command\/\">NET command<\/a> to restart a specific service at a specific time.<\/p>\n<p>To do so:<\/p>\n<h2 class=\"blog-caption-numbered\">1. Find the name of your service<\/h2>\n<p>Each Windows Service has two names &mdash; a short <b>service name<\/b> and a friendly <b>display name<\/b>. We need the service name for the NET command. <\/p>\n<p>If you don&#8217;t already know the service name, or want to validate it:<\/p>\n<ol>\n<li>\n<p>Launch the <a href=\"\/blog\/windows-services\/essential-tools-windows-services-msc\/\">Windows Services application<\/a>. You can find it by searching for &#8220;services&#8221; in the Control Panel, or by running <b>services.msc<\/b> at a command prompt.<\/p>\n<\/li>\n<li>\nScroll to locate your service in the list:<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/services-print-spooler.png\" class=\"zoomPopup\" title=\"Windows Services application\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/services-print-spooler.png\" title=\"Windows Services application (click to enlarge)\" alt=\"Windows Services application\" border=\"0\" width=\"520\" \/><\/a><\/div>\n<\/li>\n<li>\n<p>Double-click the entry to open the service&#8217;s properties. The service name is displayed at the top.<\/p>\n<\/li>\n<\/ol>\n<p>Here we see that the name of the Print Spooler service is actually &#8220;Spooler&#8221;:<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/print-spooler-service-name.png\" class=\"zoomPopup\" title=\"Print Spooler service name\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/print-spooler-service-name.png\" title=\"Print Spooler service name (click to enlarge)\" alt=\"Print Spooler service name\" border=\"0\" \/><\/a><\/div>\n<h2 class=\"blog-caption-numbered\">2. Create a batch file to restart your service<\/h2>\n<p>With the service name in hand, we can now use the NET command to restart the service.<\/p>\n<p>Create a new batch file and enter the following two commands:<\/p>\n<div class=\"code-box\">\n   NET STOP &quot;<i>Your Service Name<\/i>&quot;<br \/>\n   NET START &quot;<i>Your Service Name<\/i>&quot;\n<\/div>\n<p>Please replace <i>Your Service Name<\/i> with the service name identified in step 1. The quotes are required if the service name contains a space.<\/p>\n<p>For example, if your service name is &#8220;Spooler&#8221;, the batch file should look like this:<\/p>\n<div class=\"code-box\">\n   NET STOP &quot;Spooler&quot;<br \/>\n   NET START &quot;Spooler&quot;\n<\/div>\n<p>Save the batch file to a well-known location. We&#8217;ll use it in the next step.<\/p>\n<h3>Test the batch file<\/h3>\n<p>At this point, we recommend performing a quick test to ensure that the batch file works as expected. Run it from an administrative command prompt and confirm that it restarts your service.<\/p>\n<h2 class=\"blog-caption-numbered\">3. Create a scheduled task to run the batch file at the time you wish to restart the service<\/h2>\n<p>Now that you are able to restart the service with the batch file, let&#8217;s schedule it to run whenever you like.<\/p>\n<p>For example, here is how we would restart the Print Spooler service every Sunday at 1 AM:<\/p>\n<ol>\n<li>\n<p>Open the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Windows_Task_Scheduler\" target=\"_blank\" rel=\"noopener noreferrer\">Windows Task Scheduler<\/a>. You start it from the Control Panel or by running <b>taskschd.msc<\/b> from a command prompt.<\/p>\n<\/li>\n<li>\n<p>Click <b>Create Basic Task<\/b> on the right:<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/task-scheduler-click-create-basic-task.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-click-create-basic-task.png\" title=\"Task Scheduler: Create Basic Task (click to enlarge)\" alt=\"Task Scheduler: Create Basic Task\" border=\"0\" \/><\/a><\/div>\n<p>The <b>Create Basic Task Wizard<\/b> window will come up.<\/p>\n<\/li>\n<li>\n<p>Give the task a descriptive name:<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/create-basic-task-set-name.png\" class=\"zoomPopup\" title=\"Enter the task name\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/create-basic-task-set-name.png\" title=\"Enter the task name (click to enlarge)\" alt=\"Enter the task name\" border=\"0\" \/><\/a><\/div>\n<p>Click <b>Next<\/b> to continue.<\/p>\n<\/li>\n<li>\n<p>Select <b>Weekly<\/b> and click <b>Next<\/b>:<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/create-basic-task-weekly.png\" class=\"zoomPopup\" title=\"Set the task to run weekly\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/create-basic-task-weekly.png\" title=\"Set the task to run weekly (click to enlarge)\" alt=\"Set the task to run weekly\" border=\"0\" \/><\/a><\/div>\n<\/li>\n<li>\n<p>Set the day and time to restart the service:<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/create-basic-task-set-date-time.png\" class=\"zoomPopup\" title=\"Set the day and time to restart the service\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/create-basic-task-set-date-time.png\" title=\"Set the day and time to restart the service (click to enlarge)\" alt=\"Set the day and time to restart the service\" border=\"0\" \/><\/a><\/div>\n<p>Click <b>Next<\/b> to continue.<\/p>\n<\/li>\n<li>\n<p>Ensure that the action is <b>Start a program<\/b> and move to the next step:<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/create-basic-task-set-action.png\" class=\"zoomPopup\" title=\"Set the action - Start a program\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/create-basic-task-set-action.png\" title=\"Set the action - Start a program (click to enlarge)\" alt=\"Set the action - Start a program\" border=\"0\" \/><\/a><\/div>\n<\/li>\n<li>\n<p>Enter the full path to the batch file you created to restart the service:<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/create-basic-task-set-batch-file.png\" class=\"zoomPopup\" title=\"Specify the batch file to restart the service\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/create-basic-task-set-batch-file.png\" title=\"Specify the batch file to restart the service (click to enlarge)\" alt=\"Specify the batch file to restart the service\" border=\"0\" \/><\/a><\/div>\n<p>Click <b>Next<\/b> to continue.<\/p>\n<\/li>\n<li>\n<p>Review the summary and make sure that everything looks good.<\/p>\n<p>Check the <b>Open the Properties dialog&#8230;<\/b> box at the bottom because we&#8217;ll need to adjust one of the tasks properties:<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/create-basic-task-summary.png\" class=\"zoomPopup\" title=\"Review the summary of the task\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/create-basic-task-summary.png\" title=\"Review the summary of the task (click to enlarge)\" alt=\"Review the summary of the task\" border=\"0\" \/><\/a><\/div>\n<p>Click <b>Finish<\/b>.<\/p>\n<\/li>\n<li>\n<p>And finally, in the Properties window, check the <b>Run with highest privileges<\/b> box. The batch file must run with administrative rights so that it can restart the service.<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/run-service-task-with-highest-privileges.png\" class=\"zoomPopup\" title=\"Run the task with highest privileges\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/run-service-task-with-highest-privileges.png\" title=\"Run the task with highest privileges (click to enlarge)\" alt=\"Run the task with highest privileges\" border=\"0\" \/><\/a><\/div>\n<p>Click <b>OK<\/b> to save your settings.<\/p>\n<\/li>\n<\/ol>\n<p>Going forward, the new task will come alive at the scheduled time to promptly restart the service. You should be good to go.<\/p>\n<h2 class=\"blog-caption\">Improvement: Use ServicePilot instead of NET for better reliability<\/h2>\n<div align=\"center\"><img decoding=\"async\" src=\"\/blog\/images\/optimize.png\" title=\"Use ServicePilot instead of NET.EXE\" alt=\"Use ServicePilot instead of NET.EXE\" border=\"0\"><\/div>\n<p>While NET.EXE will work for most situations, there are a few scenarios where it may fall short.<\/p>\n<p>Does your service:<\/p>\n<ul>\n<li>take longer than 30 seconds to shut down?<\/li>\n<li>occasionally hang and refuse to stop?<\/li>\n<\/ul>\n<p>If so, the NET STOP command may fail. And when that happens, the subsequent call to NET START will fail too (because the service will not be idle). The end result is that your service will be left in an unusable\/unresponsive state!<\/p>\n<p>Our <a href=\"\/products\/ServicePilot\/\">free ServicePilot utility<\/a> was built to work around NET&#8217;s shortcomings. It will wait for longer than 30 seconds if necessary and will do its best to forcibly terminate an unresponsive service.<\/p>\n<p>To use ServicePilot instead of NET:<\/p>\n<ol>\n<li>\n<p>Download ServicePilot from our website. Save the executable in a well-known location (e.g. C:\\Apps\\ServicePilot\\ServicePilot.exe).<\/p>\n<\/li>\n<li>\n<p>Edit the batch file you created to restart the service.<\/p>\n<\/li>\n<li>\n<p>Delete the two NET lines.<\/p>\n<\/li>\n<li>\n<p>Add the following line (adjusting the full path to ServicePilot and your service name as necessary):<\/p>\n<div class=\"code-box\">\n   C:\\Apps\\ServicePilot\\ServicePilot.exe -restart -wait 300 &quot;<i>Your Service Name<\/i>&quot;\n<\/div>\n<p>Note: The <b>-wait 300<\/b> parameter instructs ServicePilot to wait up to 300 seconds (5 minutes) for the service to stop and restart. Feel free to increase (or decrease) the timeout based your specific use case.<\/p>\n<\/li>\n<li>\n<p>Save the batch file.<\/p>\n<\/li>\n<\/ol>\n<p>As you did with the NET version, please perform a quick test to ensure that the updated batch file works as expected. Launch it from an administrative command prompt and confirm that it restarts your service.<\/p>\n<p style=\"margin-top:30px;\">\nBest of luck with your service!\n<\/p>\n<hr style=\"margin-top:40px\">\n<h2 class=\"blog-caption\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/cdn.coretechnologies.com\/images\/new_small.gif\" alt=\"New!\" width=\"28\" height=\"11\" border=\"0\">&nbsp;UPDATE: Use our free Service Scheduler utility instead of the Task Scheduler<\/h2>\n<p>We got tired of manually creating batch files and scheduled tasks to control our services so we created a <b>free application<\/b> to do it all. \ud83d\ude42<\/p>\n<p>With <a href=\"\/products\/ServiceScheduler\/\">Service Scheduler<\/a>, you can easily start, stop or restart any Windows Service &mdash; daily, weekly or monthly at a time of your choosing:<\/p>\n<div align=\"center\"><a href=\"\/products\/ServiceScheduler\/service-scheduler-screenshot.png\" class=\"zoomPopup\" title=\"Service Scheduler\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/products\/ServiceScheduler\/service-scheduler-screenshot.png\" title=\"Service Scheduler (click to enlarge)\" alt=\"Service Scheduler\" border=\"0\" width=\"520\" \/><\/a><\/div>\n<p>Service Scheduler is completely free and super easy to use. You can schedule your service in seconds:<\/p>\n<div align=\"center\"><a href=\"\/products\/ServiceScheduler\/service-scheduler-add-daily-task.png\" class=\"zoomPopup\" title=\"Service Scheduler: Add Daily Service Task\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/products\/ServiceScheduler\/service-scheduler-add-daily-task.png\" title=\"Service Scheduler: Add Daily Service Task (click to enlarge)\" alt=\"Service Scheduler: Add Daily Service Task\" border=\"0\" \/><\/a><\/div>\n<p><a href=\"\/products\/ServiceScheduler\/\">Download Service Scheduler<\/a> and check it out today!<\/p>\n<hr style=\"margin-top:30px\">\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\/windows-services\/startup-types-explained\/\"class=\"relpost-block-single\" ><div class=\"relpost-custom-block-single\"><img decoding=\"async\" loading=\"lazy\" class=\"relpost-block-single-image\" alt=\"Windows Services Startup Types Explained\"  src=\"https:\/\/www.coretechnologies.com\/blog\/wp-content\/uploads\/windows-service-startup-types-150x150-1.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\">Windows Services Startup Types Explained<\/h2><\/div><\/div><\/a><a href=\"https:\/\/www.coretechnologies.com\/blog\/alwaysup\/trinium-replaces-task-scheduler\/\"class=\"relpost-block-single\" ><div class=\"relpost-custom-block-single\"><img decoding=\"async\" loading=\"lazy\" class=\"relpost-block-single-image\" alt=\"Customer Spotlight\"  src=\"https:\/\/www.coretechnologies.com\/blog\/wp-content\/uploads\/cusomer-spotlight-150x150.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\">&quot;We replaced Windows Task Scheduler with AlwaysUp and never looked back!&quot;<\/h2><\/div><\/div><\/a><a href=\"https:\/\/www.coretechnologies.com\/blog\/alwaysup\/backup-and-sync-service-status\/\"class=\"relpost-block-single\" ><div class=\"relpost-custom-block-single\"><img decoding=\"async\" loading=\"lazy\" class=\"relpost-block-single-image\" alt=\"Q&amp;A: What is the Status of my Backup and Sync Windows Service?\"  src=\"https:\/\/www.coretechnologies.com\/blog\/wp-content\/uploads\/clipboard-150x150.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: What is the Status of my Backup and Sync Windows Service?<\/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;I want to restart some specific service for a specific time every week. Can I use the NET command? &mdash; Shanmuga Hi Shanmuga. Yes. With the help of the Windows Task Scheduler, you can use the NET command to restart &hellip; <a href=\"https:\/\/www.coretechnologies.com\/blog\/windows-services\/how-to-restart-at-specific-time\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":9069,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[108,127,145,292,164,196],"class_list":["post-8739","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-windows-services","tag-net-exe","tag-qa","tag-service-pilot","tag-service-scheduler","tag-task-scheduler","tag-windows-services-2"],"_links":{"self":[{"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/8739","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=8739"}],"version-history":[{"count":41,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/8739\/revisions"}],"predecessor-version":[{"id":11494,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/8739\/revisions\/11494"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/media\/9069"}],"wp:attachment":[{"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/media?parent=8739"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/categories?post=8739"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/tags?post=8739"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}