Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm having some problems with running the command prompt with administrator privileges.

I'm use this command, to run as a specific user:

runas /user:DOMAIN\MYUSER cmd

The user DOMAIN\MYUSER is member of DOMAIN\Domain Administrators who are in the local Administrators group.

But when I try to run net start/stop MyService I get an access denied error. Any suggestions?

share|improve this question

4 Answers 4

I have a similar problem on Windows 7 Professional.

When I'm in PowerShell and type runas /user:UserAdmin cmd it asks me for my password within PowerShell and I get a command prompt with a window title that says cmd (running as hostname\UserAdmin). When trying to start or stop a service with net start MyService in this new prompt I get an access denied error.

However, if I use the command start-process cmd -verb runas, the graphical UAC dialog pops up and asks for my credentials, and then opens a command prompt with a window title that says Administrator: C:\windows\system32\cmd.exe... apparently these are two different things since net start MyService works fine in this one.

You might be able to use the latter method to run your script (using a .PS1 PowerShell script instead of a simple .BAT file)

Note: UserAdmin is a local machine user account that is a member of the Administrators group.

share|improve this answer

I had exactly the same issue. I was not able to start/stop win service without "run as administrator". I thought my UAC was disabled (UAC slider was on "Do not notify" value), but disabling UAC using the slider was not sufficient. Disable UAC using Regedit to be sure the UAC is really disabled (restart is required). Now my script is working without using runas command. Hope it helps someone.

share|improve this answer

anyway - when I run my batch file as a scheduled task (where I request the maximum allowed rights) it's ok. it just don't work with runas -> e.g. I'm not anyway given the admin privileges here. but scheduled task is enough - I anyway needed to automate it.

share|improve this answer

It's a little hard to know without knowing what operating system you're trying to do this on.

If you're running an OS that has UAC, I'd try running an elevated CMD prompt first:

Login as the Admin user. Click Start, then in the Search box type CMD. Right click the CMD.exe and choose Run As Administrator. Now try your Net Stop/Start and see if it works.

If it works, then at least you can narrow down the problems (i.e. it shouldn't be a permissions problem with the specific user). If it doesn't work, then you likely have a permissions problem with that user.

Also try looking in the Event Viewer to see if it reports a specific issue (e.g. it might tell you why it can't stop/start that service).

If you upgraded from Windows Server 2003, then you might find that runas (and right-click Run As Administrator) does not work. There is a Microsoft article that provides some workarounds for this issue - see http://support.microsoft.com/kb/977513.

share|improve this answer
    
It's 2008 R2 64b. I'll try with the elevated right CMD.exe, anyway this wouldn't be the solution... Just for the check. –  rezna Sep 14 '10 at 10:39
    
Did you upgrade from Windows Server 2003? –  misterjaytee Sep 14 '10 at 11:33
    
no i didn't it a clean install –  rezna Sep 16 '10 at 6:01
    
anyway - when I run my batch file as a scheduled task (where I request the maximum allowed rights) it's ok. it just don't work with runas -> e.g. I'm not anyway given the admin privileges here. but scheduled task is enough - I anyway needed to automate it. –  rezna Sep 16 '10 at 6:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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