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"

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?


Running as Admin

enter image description here

  • 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... Oct 24, 2016 at 16:09
  • Try quoting the whole command: runas /user:Administrator "net stop \"Service Integration Gateway\""
    – DavidPostill
    Oct 24, 2016 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, 2016 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". Oct 24, 2016 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, 2016 at 23:11

1 Answer 1


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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .