Windows – runas with administrator privileges

administratorrunaswindows-server-2008-r2

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?

Best 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.

Related Question