I have a little problem with running command-line with administrator privileges.

I use this command, to be sure to run as a specific user:

runas /user:DOMAIN\MYUSER cmd

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

Anyway, when I try to run

net start/stop MyService

I would get access denied.

Any suggestions? :( Thx rezna

link|improve this question
feedback

3 Answers

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.

link|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
feedback

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.

link|improve this answer
feedback

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.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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