Access denied when using net stop/start via CLI on Windows 7











up vote
1
down vote

favorite












I have a Windows service that needs to be stopped and restarted when switching to a different development server (I'm a web developer.) If I go into the Services GUI, I can stop and restart the service with no problem. My colleague has a batch file that works for him, so I tried to use it, and it's giving me Access Denied errors. I've tried running the file as administrator, and even just running the commands directly in the cmd window. Still get the error.



The file is simply:



net stop "Service Integration Gateway"
net start "Service Integration Gateway"
pause


I found this answer on StackOverflow, and tried using the runas command like this:



runas /user:Administrator net stop "Service Integration Gateway"


but all it did was give me the readme on runas, so I'm guessing I can't use it with the net stop command, or I'm using it wrong.



What do I need to do to be able to run these commands via CLI/batch?



EDITED TO ADD SCREENSHOT AS REQUESTED:



Running as Admin



enter image description here










share|improve this question
























  • In your picture, your CMD window is NOT running "as administrator"; can you provide a screenshot of it failing in a command prompt that's been "run as administrator"? As to your RunAs toubles, the "program" needs to be a single string that contains both the program and options, so you'll want to encapsulate it in quotes (and escape the inner quotes) like this: runas /user:Administrator "net stop "Service Integration Gateway"" See runas /? for more information...
    – Ƭᴇcʜιᴇ007
    Oct 24 '16 at 16:09












  • Try quoting the whole command: runas /user:Administrator "net stop "Service Integration Gateway""
    – DavidPostill
    Oct 24 '16 at 16:11










  • @Ƭᴇcʜιᴇ007 - I've added a screenshot of the cmd window running as admin. As you can see, the error message is the same.
    – EmmyS
    Oct 24 '16 at 20:51










  • It still doesn't appear that you're running the command-prompt "As administrator", as I would expect the window title to be prefixed with "As Administrator: " to signify it. Instead of however you are launching CMD try this instead: Click Start, type CMD, and when it appears on the start menu, right-click it and choose "Run as administrator".
    – Ƭᴇcʜιᴇ007
    Oct 24 '16 at 21:00










  • @Ƭᴇcʜιᴇ007 - I'll provide a video if necessary - I'm running the prompt as administrator. It gave me the popup confirm when I clicked the shortcut to it. It does the same thing if I do it via the start menu as you detail.
    – EmmyS
    Oct 26 '16 at 23:11















up vote
1
down vote

favorite












I have a Windows service that needs to be stopped and restarted when switching to a different development server (I'm a web developer.) If I go into the Services GUI, I can stop and restart the service with no problem. My colleague has a batch file that works for him, so I tried to use it, and it's giving me Access Denied errors. I've tried running the file as administrator, and even just running the commands directly in the cmd window. Still get the error.



The file is simply:



net stop "Service Integration Gateway"
net start "Service Integration Gateway"
pause


I found this answer on StackOverflow, and tried using the runas command like this:



runas /user:Administrator net stop "Service Integration Gateway"


but all it did was give me the readme on runas, so I'm guessing I can't use it with the net stop command, or I'm using it wrong.



What do I need to do to be able to run these commands via CLI/batch?



EDITED TO ADD SCREENSHOT AS REQUESTED:



Running as Admin



enter image description here










share|improve this question
























  • In your picture, your CMD window is NOT running "as administrator"; can you provide a screenshot of it failing in a command prompt that's been "run as administrator"? As to your RunAs toubles, the "program" needs to be a single string that contains both the program and options, so you'll want to encapsulate it in quotes (and escape the inner quotes) like this: runas /user:Administrator "net stop "Service Integration Gateway"" See runas /? for more information...
    – Ƭᴇcʜιᴇ007
    Oct 24 '16 at 16:09












  • Try quoting the whole command: runas /user:Administrator "net stop "Service Integration Gateway""
    – DavidPostill
    Oct 24 '16 at 16:11










  • @Ƭᴇcʜιᴇ007 - I've added a screenshot of the cmd window running as admin. As you can see, the error message is the same.
    – EmmyS
    Oct 24 '16 at 20:51










  • It still doesn't appear that you're running the command-prompt "As administrator", as I would expect the window title to be prefixed with "As Administrator: " to signify it. Instead of however you are launching CMD try this instead: Click Start, type CMD, and when it appears on the start menu, right-click it and choose "Run as administrator".
    – Ƭᴇcʜιᴇ007
    Oct 24 '16 at 21:00










  • @Ƭᴇcʜιᴇ007 - I'll provide a video if necessary - I'm running the prompt as administrator. It gave me the popup confirm when I clicked the shortcut to it. It does the same thing if I do it via the start menu as you detail.
    – EmmyS
    Oct 26 '16 at 23:11













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I have a Windows service that needs to be stopped and restarted when switching to a different development server (I'm a web developer.) If I go into the Services GUI, I can stop and restart the service with no problem. My colleague has a batch file that works for him, so I tried to use it, and it's giving me Access Denied errors. I've tried running the file as administrator, and even just running the commands directly in the cmd window. Still get the error.



The file is simply:



net stop "Service Integration Gateway"
net start "Service Integration Gateway"
pause


I found this answer on StackOverflow, and tried using the runas command like this:



runas /user:Administrator net stop "Service Integration Gateway"


but all it did was give me the readme on runas, so I'm guessing I can't use it with the net stop command, or I'm using it wrong.



What do I need to do to be able to run these commands via CLI/batch?



EDITED TO ADD SCREENSHOT AS REQUESTED:



Running as Admin



enter image description here










share|improve this question















I have a Windows service that needs to be stopped and restarted when switching to a different development server (I'm a web developer.) If I go into the Services GUI, I can stop and restart the service with no problem. My colleague has a batch file that works for him, so I tried to use it, and it's giving me Access Denied errors. I've tried running the file as administrator, and even just running the commands directly in the cmd window. Still get the error.



The file is simply:



net stop "Service Integration Gateway"
net start "Service Integration Gateway"
pause


I found this answer on StackOverflow, and tried using the runas command like this:



runas /user:Administrator net stop "Service Integration Gateway"


but all it did was give me the readme on runas, so I'm guessing I can't use it with the net stop command, or I'm using it wrong.



What do I need to do to be able to run these commands via CLI/batch?



EDITED TO ADD SCREENSHOT AS REQUESTED:



Running as Admin



enter image description here







windows-7 command-line batch






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited May 23 '17 at 12:41









Community

1




1










asked Oct 24 '16 at 15:57









EmmyS

92891733




92891733












  • In your picture, your CMD window is NOT running "as administrator"; can you provide a screenshot of it failing in a command prompt that's been "run as administrator"? As to your RunAs toubles, the "program" needs to be a single string that contains both the program and options, so you'll want to encapsulate it in quotes (and escape the inner quotes) like this: runas /user:Administrator "net stop "Service Integration Gateway"" See runas /? for more information...
    – Ƭᴇcʜιᴇ007
    Oct 24 '16 at 16:09












  • Try quoting the whole command: runas /user:Administrator "net stop "Service Integration Gateway""
    – DavidPostill
    Oct 24 '16 at 16:11










  • @Ƭᴇcʜιᴇ007 - I've added a screenshot of the cmd window running as admin. As you can see, the error message is the same.
    – EmmyS
    Oct 24 '16 at 20:51










  • It still doesn't appear that you're running the command-prompt "As administrator", as I would expect the window title to be prefixed with "As Administrator: " to signify it. Instead of however you are launching CMD try this instead: Click Start, type CMD, and when it appears on the start menu, right-click it and choose "Run as administrator".
    – Ƭᴇcʜιᴇ007
    Oct 24 '16 at 21:00










  • @Ƭᴇcʜιᴇ007 - I'll provide a video if necessary - I'm running the prompt as administrator. It gave me the popup confirm when I clicked the shortcut to it. It does the same thing if I do it via the start menu as you detail.
    – EmmyS
    Oct 26 '16 at 23:11


















  • In your picture, your CMD window is NOT running "as administrator"; can you provide a screenshot of it failing in a command prompt that's been "run as administrator"? As to your RunAs toubles, the "program" needs to be a single string that contains both the program and options, so you'll want to encapsulate it in quotes (and escape the inner quotes) like this: runas /user:Administrator "net stop "Service Integration Gateway"" See runas /? for more information...
    – Ƭᴇcʜιᴇ007
    Oct 24 '16 at 16:09












  • Try quoting the whole command: runas /user:Administrator "net stop "Service Integration Gateway""
    – DavidPostill
    Oct 24 '16 at 16:11










  • @Ƭᴇcʜιᴇ007 - I've added a screenshot of the cmd window running as admin. As you can see, the error message is the same.
    – EmmyS
    Oct 24 '16 at 20:51










  • It still doesn't appear that you're running the command-prompt "As administrator", as I would expect the window title to be prefixed with "As Administrator: " to signify it. Instead of however you are launching CMD try this instead: Click Start, type CMD, and when it appears on the start menu, right-click it and choose "Run as administrator".
    – Ƭᴇcʜιᴇ007
    Oct 24 '16 at 21:00










  • @Ƭᴇcʜιᴇ007 - I'll provide a video if necessary - I'm running the prompt as administrator. It gave me the popup confirm when I clicked the shortcut to it. It does the same thing if I do it via the start menu as you detail.
    – EmmyS
    Oct 26 '16 at 23:11
















In your picture, your CMD window is NOT running "as administrator"; can you provide a screenshot of it failing in a command prompt that's been "run as administrator"? As to your RunAs toubles, the "program" needs to be a single string that contains both the program and options, so you'll want to encapsulate it in quotes (and escape the inner quotes) like this: runas /user:Administrator "net stop "Service Integration Gateway"" See runas /? for more information...
– Ƭᴇcʜιᴇ007
Oct 24 '16 at 16:09






In your picture, your CMD window is NOT running "as administrator"; can you provide a screenshot of it failing in a command prompt that's been "run as administrator"? As to your RunAs toubles, the "program" needs to be a single string that contains both the program and options, so you'll want to encapsulate it in quotes (and escape the inner quotes) like this: runas /user:Administrator "net stop "Service Integration Gateway"" See runas /? for more information...
– Ƭᴇcʜιᴇ007
Oct 24 '16 at 16:09














Try quoting the whole command: runas /user:Administrator "net stop "Service Integration Gateway""
– DavidPostill
Oct 24 '16 at 16:11




Try quoting the whole command: runas /user:Administrator "net stop "Service Integration Gateway""
– DavidPostill
Oct 24 '16 at 16:11












@Ƭᴇcʜιᴇ007 - I've added a screenshot of the cmd window running as admin. As you can see, the error message is the same.
– EmmyS
Oct 24 '16 at 20:51




@Ƭᴇcʜιᴇ007 - I've added a screenshot of the cmd window running as admin. As you can see, the error message is the same.
– EmmyS
Oct 24 '16 at 20:51












It still doesn't appear that you're running the command-prompt "As administrator", as I would expect the window title to be prefixed with "As Administrator: " to signify it. Instead of however you are launching CMD try this instead: Click Start, type CMD, and when it appears on the start menu, right-click it and choose "Run as administrator".
– Ƭᴇcʜιᴇ007
Oct 24 '16 at 21:00




It still doesn't appear that you're running the command-prompt "As administrator", as I would expect the window title to be prefixed with "As Administrator: " to signify it. Instead of however you are launching CMD try this instead: Click Start, type CMD, and when it appears on the start menu, right-click it and choose "Run as administrator".
– Ƭᴇcʜιᴇ007
Oct 24 '16 at 21:00












@Ƭᴇcʜιᴇ007 - I'll provide a video if necessary - I'm running the prompt as administrator. It gave me the popup confirm when I clicked the shortcut to it. It does the same thing if I do it via the start menu as you detail.
– EmmyS
Oct 26 '16 at 23:11




@Ƭᴇcʜιᴇ007 - I'll provide a video if necessary - I'm running the prompt as administrator. It gave me the popup confirm when I clicked the shortcut to it. It does the same thing if I do it via the start menu as you detail.
– EmmyS
Oct 26 '16 at 23:11










2 Answers
2






active

oldest

votes

















up vote
0
down vote













The problem is not necessarily related to user permissions. In my case for example it crashed as it was initializing because of wrong connection string and the message was "Access denied". Check Event viewer.






share|improve this answer




























    up vote
    0
    down vote













    Your command prompt screenshot doesn't say "Administrator" at the front so I think possibly you are not doing "run as administrator" correctly. Make sure to right click the bat file and do "run as administrator" which has a yellow/blue shield icon. Do NOT use "run as different user" or assume when logged on as an admin that you have full admin rights. UAC prevents certain actions without further elevation.



    enter image description here



    enter image description here






    share|improve this answer





















      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "3"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1138435%2faccess-denied-when-using-net-stop-start-via-cli-on-windows-7%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      0
      down vote













      The problem is not necessarily related to user permissions. In my case for example it crashed as it was initializing because of wrong connection string and the message was "Access denied". Check Event viewer.






      share|improve this answer

























        up vote
        0
        down vote













        The problem is not necessarily related to user permissions. In my case for example it crashed as it was initializing because of wrong connection string and the message was "Access denied". Check Event viewer.






        share|improve this answer























          up vote
          0
          down vote










          up vote
          0
          down vote









          The problem is not necessarily related to user permissions. In my case for example it crashed as it was initializing because of wrong connection string and the message was "Access denied". Check Event viewer.






          share|improve this answer












          The problem is not necessarily related to user permissions. In my case for example it crashed as it was initializing because of wrong connection string and the message was "Access denied". Check Event viewer.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Dec 14 '17 at 7:27









          Gabriel

          11




          11
























              up vote
              0
              down vote













              Your command prompt screenshot doesn't say "Administrator" at the front so I think possibly you are not doing "run as administrator" correctly. Make sure to right click the bat file and do "run as administrator" which has a yellow/blue shield icon. Do NOT use "run as different user" or assume when logged on as an admin that you have full admin rights. UAC prevents certain actions without further elevation.



              enter image description here



              enter image description here






              share|improve this answer

























                up vote
                0
                down vote













                Your command prompt screenshot doesn't say "Administrator" at the front so I think possibly you are not doing "run as administrator" correctly. Make sure to right click the bat file and do "run as administrator" which has a yellow/blue shield icon. Do NOT use "run as different user" or assume when logged on as an admin that you have full admin rights. UAC prevents certain actions without further elevation.



                enter image description here



                enter image description here






                share|improve this answer























                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  Your command prompt screenshot doesn't say "Administrator" at the front so I think possibly you are not doing "run as administrator" correctly. Make sure to right click the bat file and do "run as administrator" which has a yellow/blue shield icon. Do NOT use "run as different user" or assume when logged on as an admin that you have full admin rights. UAC prevents certain actions without further elevation.



                  enter image description here



                  enter image description here






                  share|improve this answer












                  Your command prompt screenshot doesn't say "Administrator" at the front so I think possibly you are not doing "run as administrator" correctly. Make sure to right click the bat file and do "run as administrator" which has a yellow/blue shield icon. Do NOT use "run as different user" or assume when logged on as an admin that you have full admin rights. UAC prevents certain actions without further elevation.



                  enter image description here



                  enter image description here







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Sep 28 at 20:53









                  duct_tape_coder

                  1592




                  1592






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Super User!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.





                      Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                      Please pay close attention to the following guidance:


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1138435%2faccess-denied-when-using-net-stop-start-via-cli-on-windows-7%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

                      Mangá

                      Eduardo VII do Reino Unido