{"id":9371,"date":"2020-08-23T19:48:09","date_gmt":"2020-08-24T02:48:09","guid":{"rendered":"https:\/\/www.coretechnologies.com\/blog\/?p=9371"},"modified":"2022-04-19T21:53:58","modified_gmt":"2022-04-20T04:53:58","slug":"sc-service-fails-to-start","status":"publish","type":"post","link":"https:\/\/www.coretechnologies.com\/blog\/windows-services\/sc-service-fails-to-start\/","title":{"rendered":"Q&#038;A: I created a Windows Service with SC. Why won&#8217;t it Start?"},"content":{"rendered":"<div align=\"center\"><img loading=\"lazy\" decoding=\"async\" class=\"no-lazy-load\" src=\"\/blog\/images\/qa-sc-service-fails-to-start.webp\" title=\"Q&#038;A: SC Windows Service won't start\" alt=\"Q&#038;A: SC Windows Service won't start\" border=\"0\" width=\"380\" height=\"160\" \/><\/div>\n<div class=\"blog-qa-question-box\">\n<img loading=\"lazy\" decoding=\"async\" class=\"no-lazy-load\" src=\"https:\/\/cdn.coretechnologies.com\/images\/quotes-transparent-21x21.webp\" width=\"21\" height=\"21\" \/>&nbsp;&nbsp;I installed my program as a Windows Service using the <a href=\"\/blog\/windows-services\/essential-tools-windows-services-sc-exe\/\">SC command<\/a>. The result was &#8220;CreateService SUCCESS&#8221;, and my service is listed with all the others so I know it worked.<\/p>\n<p>But whenever I try to start the service, the NET command fails with &#8220;The service is not responding to the control function&#8221;. What does that mean? Why can&#8217;t I start the service?<\/p>\n<p align=\"right\">&mdash; Marc B.<\/p>\n<\/div>\n<p>Hi Marc.<\/p>\n<p>You are running into a common problem with the SC utility. While SC will happily install any script, batch file or executable as a service, <b>the service it creates may not be usable!<\/b><\/p>\n<p>Let&#8217;s dig into the details.<\/p>\n<h2 class=\"blog-caption\">SC is not picky; it will install <i>anything<\/i> as a service<\/h2>\n<p>As you have discovered, the &#8220;SC CREATE&#8221; command will create a new Windows Service. The command line must look like this:<\/p>\n<blockquote><p><b>SC CREATE &lt;SERVICE-NAME&gt; binpath= &quot;&lt;FULL-PATH-TO-PROGRAM&gt;&quot;<\/b><\/p><\/blockquote>\n<p>(Yes &mdash; the space after &#8220;binpath=&#8221; is required!)<\/p>\n<p>Apparently all you need to specify is a friendly name and the full path to your program for SC to work it&#8217;s magic. Simple, right?<\/p>\n<p>For example, to install the Windows Notepad application as a service called &#8220;NotepadService&#8221;, run this command from an <a href=\"\/WindowsServices\/FAQ.html#ElevatedPrompt\">administrative command prompt<\/a>:<\/p>\n<blockquote><p><b>SC CREATE NotepadService binpath= &quot;C:\\Windows\\Notepad.exe&quot;<\/b><\/p><\/blockquote>\n<p>SC will confirm success:<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/sc-create-new-service.png\" class=\"zoomPopup\" title=\"SC creates a new service\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/sc-create-new-service.png\" title=\"SC creates a new service (click to enlarge)\" alt=\"SC creates a new service\" border=\"0\" width=\"520\" \/><\/a><\/div>\n<p>And the new service will be listed in the <a href=\"\/blog\/windows-services\/essential-tools-windows-services-msc\/\">Services application<\/a>:<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/new-service-in-services-application.png\" class=\"zoomPopup\" title=\"New service in services.msc\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/new-service-in-services-application.png\" title=\"New service in services.msc (click to enlarge)\" alt=\"New service in services.msc\" border=\"0\" width=\"520\" \/><\/a><\/div>\n<p>But there are limits to what SC will do. Even as it dutifully performs the basic operations &mdash; creating the necessary entries in the Windows Registry &mdash; SC will not validate the path\/program in any way. This means that:<\/p>\n<ol type=\"a\">\n<li>\nSC will succeed even if the <b>program does not exist<\/b>. You can give it a bogus path and see:<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/sc-installs-non-existent-program.png\" class=\"zoomPopup\" title=\"SC installs non-existent program\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/sc-installs-non-existent-program.png\" title=\"SC installs non-existent program (click to enlarge)\" alt=\"SC installs non-existent program\" border=\"0\" width=\"520\" \/><\/a><\/div>\n<p>However, the following error pops up when you try to start the &#8220;BadPath&#8221; service installed above:<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/start-service-bad-path-error.png\" class=\"zoomPopup\" title=\"You can't start a service with a bad path\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/start-service-bad-path-error.png\" title=\"You can't start a service with a bad path (click to enlarge)\" alt=\"You can't start a service with a bad path\" border=\"0\" \/><\/a><\/div>\n<\/li>\n<li>\nSC will succeed even if the <b>program cannot run<\/b>. For example, here we have installed a ridiculous service where the path is an MP3 music file:<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/sc-create-mp3-service.png\" class=\"zoomPopup\" title=\"SC creates an MP3 service\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/sc-create-mp3-service.png\" title=\"SC creates an MP3 service (click to enlarge)\" alt=\"SC creates an MP3 service\" border=\"0\" width=\"520\" \/><\/a><\/div>\n<p>Indeed, as an MP3 is not a valid application, it is no surprise that attempting to start the service results in failure:<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/start-service-non-runnable-file-error.png\" class=\"zoomPopup\" title=\"You can't start a MP3 file as a service\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/start-service-non-runnable-file-error.png\" title=\"You can't start a MP3 file as a service (click to enlarge)\" alt=\"You can't start a MP3 file as a service\" border=\"0\" \/><\/a><\/div>\n<\/li>\n<\/ol>\n<p>So, as we have shown, SC is firmly focused on basic installation &mdash; not operation. The fact that a service was created with SC does not mean that the service can ever start or run.<\/p>\n<h2 class=\"blog-caption\">Only a &#8220;true&#8221; Windows Service Application can be started as a service<\/h2>\n<p>Even though SC will install any program as a service, the reality is that only specially constructed executables can actually operate as a service. We call those <b>Service Applications<\/b>.<\/p>\n<p>Service applications implement the <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/services\/service-functions\" target=\"_blank\" rel=\"noopener noreferrer\">Windows Services API<\/a> &mdash; a set of operations used to control and monitor services. Windows uses the API to interact with Service Applications.<\/p>\n<p>The API is quite extensive. With it, Windows can command any Service Application to:<\/p>\n<ul>\n<li>\nstart running\n<\/li>\n<li>\nstop running\n<\/li>\n<li>\nreport status\n<\/li>\n<li>\npause\n<\/li>\n<li>\nresume running\n<\/li>\n<li>\nprepare for system shutdown\n<\/li>\n<\/ul>\n<p>Unfortunately <a href=\"\/blog\/windows-services\/windows-service-vs-regular-application\/\">regular desktop applications<\/a> (like Microsoft Word, Google Chrome and Adobe Acrobat Reader) do not support the Windows Services API. They are not Service Applications. <b>There is simply no way for Windows to directly control or interrogate any of those desktop programs as a service.<\/b><\/p>\n<h2 class=\"blog-caption\">Non-Service Applications will fail to start, citing error 1053<\/h2>\n<p>To illustrate, let&#8217;s take Dropbox &mdash; a leading cloud storage provider. The company produces Dropbox.exe, a desktop application that synchronizes files between your PC and the cloud. Dropbox.exe is not a service application.<\/p>\n<p>As you can see, SC has no problem installing Dropbox as a service:<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/sc-create-dropbox-service.png\" class=\"zoomPopup\" title=\"SC creates Dropbox service\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/sc-create-dropbox-service.png\" title=\"SC creates Dropbox service (click to enlarge)\" alt=\"SC creates Dropbox service\" border=\"0\" width=\"520\" \/><\/a><\/div>\n<p>But when you try to start the Dropbox Service from the Services application, a curious scenario plays out:<\/p>\n<ol>\n<li>\nWindows starts Dropbox.exe. <\/p>\n<p>Here you can see Dropbox (and its <a href=\"\/blog\/dropbox-software\/why-three-processes\/\">two helper processes<\/a>) running in <a href=\"\/blog\/windows-services\/essential-tools-for-windows-services-process-explorer\/\">Process Explorer<\/a>:<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/process-explorer-dropbox-started.png\" class=\"zoomPopup\" title=\"Dropbox.exe has been started\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/process-explorer-dropbox-started.png\" title=\"Dropbox.exe has been started (click to enlarge)\" alt=\"Dropbox.exe has been started\" border=\"0\" width=\"520\" \/><\/a><\/div>\n<\/li>\n<li>\nNext, the Service Control window will report that &#8220;Windows is attempting to start&#8221; the service:<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/attempting-to-start-dropbox-service.png\" class=\"zoomPopup\" title=\"Windows is attempting to start the Dropbox service\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/attempting-to-start-dropbox-service.png\" title=\"Windows is attempting to start the Dropbox service (click to enlarge)\" alt=\"Windows is attempting to start the Dropbox service\" border=\"0\" width=\"520\" \/><\/a><\/div>\n<\/li>\n<li>\nAnd after about 30 seconds,  the Dropbox.exe processes vanish from the system and <a href=\"\/WindowsServices\/FAQ.html#Error1053\">Error 1053<\/a> is raised:<\/p>\n<div align=\"center\"><a href=\"\/blog\/images\/dropbox-service-error-1053.png\" class=\"zoomPopup\" title=\"Dropbox service failed to start with Error 1053\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"image-padding\" src=\"\/blog\/images\/dropbox-service-error-1053.png\" title=\"Dropbox service failed to start with Error 1053 (click to enlarge)\" alt=\"Dropbox service failed to start with Error 1053\" border=\"0\" width=\"520\" \/><\/a><\/div>\n<\/li>\n<\/ol>\n<p>Even though Windows kicked off Dropbox.exe as intended, the process was terminated in less than 40 seconds. A clear failure.<\/p>\n<p>And the story is the same with other regular, non-service applications as well. They all misfire in the same way.<\/p>\n<h3>Why did the Dropbox service fail to start?<\/h2>\n<p>The problem occurs in step 2.<\/p>\n<p>After launching Dropbox.exe (step 1), Windows waits for the new process to report its status and confirm that the service has started properly. However, since Dropbox does not support the Windows Services API, it fails to respond to that <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/api\/winsvc\/nf-winsvc-queryservicestatusex\" target=\"_blank\" rel=\"noopener noreferrer\">service-specific status check<\/a>. <\/p>\n<p>And after a few seconds of lingering, Windows eventually gives up. It terminates the Dropbox.exe process (and all its sub-processes) and reports that &#8220;the application did not respond to the start or control request in a timely fashion&#8221; (i.e. error 1053).<\/p>\n<h2 class=\"blog-caption\">Use a &#8220;Service Wrapper&#8221; to install a regular program as a Windows Service<\/h2>\n<p>As demonstrated above, you cannot simply install a regular application with SC and expect the service to work. You need help from a special &#8220;go-between&#8221;.<\/p>\n<p>A <a href=\"https:\/\/en.wikipedia.org\/wiki\/Service_wrapper\" target=\"_blank\" rel=\"noopener noreferrer\">service wrapper<\/a> is a Service Application that starts and stops another application in response to important events. When a service wrapper receives a Windows Services API request, it acknowledges the request and performs the appropriate action on the application it is managing.<\/p>\n<p>For example, let&#8217;s say that we have a service wrapper configured to manage Notepad. When the service wrapper receives a &#8220;start the service&#8221; request, it would start a new instance of Notepad.exe and let Windows know that the service was started successfully.<\/p>\n<p>And when the service wrapper receives a &#8220;stop the service&#8221; demand, it would terminate the Notepad process it started before exiting itself.<\/p>\n<p>Perhaps the best known service wrapper is <a href=\"\/WindowsServices\/FAQ.html#WhatIsSrvany\">Microsoft&#8217;s Srvany<\/a>. Srvany is free and functional, but <a href=\"\/products\/AlwaysUp\/srvany.html\">has some significant shortcomings<\/a>.<\/p>\n<p>Alternatively, our <a href=\"\/products\/AlwaysUp\/\">AlwaysUp utility<\/a> is a professional service wrapper. It&#8217;s not free, but is robust and mature, and makes running your application in the background as a Windows Service super easy.<\/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\/windows-services\/legacy-desktop-application-questions\/\"class=\"relpost-block-single\" ><div class=\"relpost-custom-block-single\"><img decoding=\"async\" loading=\"lazy\" class=\"relpost-block-single-image\" alt=\"Wondering if Your Legacy Desktop Application Will Work as a Windows Service? Answer These 3 Question...\"  src=\"https:\/\/www.coretechnologies.com\/blog\/wp-content\/uploads\/3-questions-to-ask-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\">Wondering if Your Legacy Desktop Application Will Work as a Windows Service? Answer These 3 Question...<\/h2><\/div><\/div><\/a><a href=\"https:\/\/www.coretechnologies.com\/blog\/windows-services\/memory-fix-june-2020-patch\/\"class=\"relpost-block-single\" ><div class=\"relpost-custom-block-single\"><img decoding=\"async\" loading=\"lazy\" class=\"relpost-block-single-image\" alt=\"Windows Services Memory Fix (Microsoft June 2020 Patch Tuesday)\"  src=\"https:\/\/www.coretechnologies.com\/blog\/wp-content\/uploads\/software-bug-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\">Windows Services Memory Fix (Microsoft June 2020 Patch Tuesday)<\/h2><\/div><\/div><\/a><a href=\"https:\/\/www.coretechnologies.com\/blog\/alwaysup\/dropbox-selective-sync\/\"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 Dropbox Selective Sync?\"  src=\"https:\/\/www.coretechnologies.com\/blog\/wp-content\/uploads\/dropbox-selective-sync-150x150-1-150x150.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 Dropbox Selective Sync?<\/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 installed my program as a Windows Service using the SC command. The result was &#8220;CreateService SUCCESS&#8221;, and my service is listed with all the others so I know it worked. But whenever I try to start the service, the &hellip; <a href=\"https:\/\/www.coretechnologies.com\/blog\/windows-services\/sc-service-fails-to-start\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":9404,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[76,127,139,151,196],"class_list":["post-9371","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-windows-services","tag-error-1053","tag-qa","tag-sc-exe","tag-services-msc","tag-windows-services-2"],"_links":{"self":[{"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/9371","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=9371"}],"version-history":[{"count":84,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/9371\/revisions"}],"predecessor-version":[{"id":11231,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/9371\/revisions\/11231"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/media\/9404"}],"wp:attachment":[{"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/media?parent=9371"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/categories?post=9371"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.coretechnologies.com\/blog\/wp-json\/wp\/v2\/tags?post=9371"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}