Link to home
Start Free TrialLog in
Avatar of sysadmin-inq
sysadmin-inqFlag for United States of America

asked on

Access denied in Elevated cmd after using Runas command

I want to open an elevated cmd while logged in to a standard user account. I'm using this command to open an elevated command-line. The user specified in the command is in the local admin group on my computer.

runas /user:DOMAIN\USER cmd.exe

The command prompts me to enter a password. Once I've entered the correct password, another instance of the command-line opens. Next, I use a command like net stop "service", but I get an Access Denied error.

Ultimately I want to use this command to run an automated batch script on accounts without admin rights, but I can't get the runas command to even open the cmd with elevated permissions.

OS: Windows 7 Pro 64-bit
Computer is connected to Domain
No GPO stopping this command
Secondary Logon Service - Started
Avatar of CITG_Carl
CITG_Carl

When you opened CMD.exe did you 'Run as Administrator'?

Cheers
Avatar of sysadmin-inq

ASKER

Yes, I've tried that. It does not work sadly.

Maybe I should fill you in on my end goal here. I wrote a batch script that will open another script in an elevated environment. See below

runas /savecred /user:DOMAIN\USER "cmd.exe /C C:\Users\MYACCOUNT\Desktop\Script.bat

Open in new window


Script.bat contains another set of commands that require the cmd to be elevated.

I started testing these set of scripts under a local admin account as well. Just fyi

Thanks!!
Why dont you run a scheduled task with the specified elevated credentials in that?
@ CITG_Carl

I've also attempted that solution. It works for the most part, but I would like to use the Runas command. If I can't get the runas command to work then I'll cave and use the sched task

Thanks for throwing that in there
Its not something to do with UAC is it? Ive just run it now on my laptop and UAC was causing an issue.

I have right clicked cmd.exe run as administrator

runas /user:DOMAIN\User cmd


Cheers
@CITG_Carl

The computers that I will be running the script on must have UAC enabled.

I have tried right-clicking cmd.exe and choosing run as administrator, then I did the runas command, but the other cmd that opens is not running as elevated.

The problem is that the command line that opens as a result of the runas command is not opening as an elevated cmd.

Thanks!!
I've also ran this command while UAC was disabled. I still get Access denied errors.

Thanks
I've learned that the runas command can't be used to elevate cmd

Avatar of David Johnson, CD
runas command can't be used to elevate cmd Where did you read this?

HUH! I do that all of the time.. the domain\user may have to  be a member of the local administrators group which is not too difficult to implement via group policy.
ASKER CERTIFIED SOLUTION
Avatar of sysadmin-inq
sysadmin-inq
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The posted link to the article explained that the Runas command in MS-DOS does not provide an elevated cmd when calling a batch file.

The scheduled tasks route is a good solution but will not work in my circumstance.

Thanks for all of your answers, but this time I found it myself.

Regards