Local Admin - Error when running SC command from command prompt -- [SC] OpenService FAILED 5: Access is denied.

I am trying to figure out how to stop then start a service from a command prompt on a Windows 2008 server.  I am not a domain administrator, but I am a local administrator on the server I am trying to do this on.  If I am remoted into the server, and I open a command prompt and type "sc stop <service_name>", I see the following:

C:\>sc stop <service_name>
[SC] OpenService FAILED 5:

Access is denied.

Open in new window


Am I able to use the sc command in this manner?  Is there another alternative for stopping then starting a service?
LVL 9
sah18Asked:
Who is Participating?
 
Subhashish LahaCommented:
Did you try opening Command Prompt by right click and selecting "Run as Administrator"? If not then try it, it should resolve the problem.
0
 
sah18Author Commented:
subhashishlaha - perfect, that was exactly it.  quick followup on this -- I really want to run this in a batch file.  How do I do the equivalent you mentioned (running as Administrator) when running this in a batch?  I'll award points right now, as I understand this is beyond my initial question.  If you happen to know how, though, I'd greatly appreciate the help!
0
 
Subhashish LahaCommented:
@Sah18

Good to know that you got the resolution and thank you for the points.

Please create new question for your query, will reply to that.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.