I logged into a Windows 2008 R2 server as a domain user that is part of the Administrators group on the target computer. Executing the following command, I get access is denied errors:

$> sc stop ServiceName
[SC] OpenService FAILED 5:
Access is denied.

What is strange is, as the very same user, I can open up the Services GUI (Administrative Tools > Services) and start/stop the very same service no problem. This appears to be happening for all services that I try to start/stop, and it happens as any "Administrative" user on this computer (with the exception of the local admin user, which I don't have the creds for in order to test). Command line fails, but GUI works.

I also know that spelling of the service name is correct, because if I alter it to be something else, I get a different error ("The specified service does not exist..."). I do notice that I can change the casing of the service name (ServiceName vs SERVICENAME) and get access denied errors on both.

I get similar access denied messages when using "net start ServiceName" instead of the sc command.

Any idea what is going on here? Needing this to work for scripting purposes. The same scripts are working fine on a Win2003 server.

1 Answer 1


Looks like you have discovered why lots of people hate User Account Control.

You should right-click on the Command Prompt icon and select "Run As Administrator"; that will allow you to actually make use of your admin rights.

  • Problem is .... I'm trying to script this for remote execution (with psexec) from TeamCity
    – Matt
    Feb 17, 2012 at 17:02
  • 2
    Then have a look at riosec.com/Windows-UAC-PsExec.
    – Massimo
    Feb 17, 2012 at 17:04
  • Or just disable UAC on the remote system altogether. I've found "when something doesn't work, disable UAC" to be pure wisdom.
    – Massimo
    Feb 17, 2012 at 17:07
  • 1
    -h did the trick for me (as suggested in the linked article). Thank you kind sir!!
    – Matt
    Feb 17, 2012 at 17:11
  • BTW, you don't need PSEXEC to remotely control a service; sc allows you to connect to a remote machine using the syntax sc \\<servername> stop <servicename>.
    – Massimo
    Feb 17, 2012 at 17:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.