Solved

Access denied in Elevated cmd after using Runas command

Posted on 2013-06-24
11
2,259 Views
Last Modified: 2013-07-06
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
0
Comment
Question by:sysadmin-inq
  • 7
  • 3
11 Comments
 
LVL 3

Expert Comment

by:CITG_Carl
ID: 39272490
When you opened CMD.exe did you 'Run as Administrator'?

Cheers
0
 

Author Comment

by:sysadmin-inq
ID: 39272551
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!!
0
 
LVL 3

Expert Comment

by:CITG_Carl
ID: 39272555
Why dont you run a scheduled task with the specified elevated credentials in that?
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

Author Comment

by:sysadmin-inq
ID: 39272594
@ 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
0
 
LVL 3

Expert Comment

by:CITG_Carl
ID: 39272638
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
0
 

Author Comment

by:sysadmin-inq
ID: 39272658
@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!!
0
 

Author Comment

by:sysadmin-inq
ID: 39272693
I've also ran this command while UAC was disabled. I still get Access denied errors.

Thanks
0
 

Author Comment

by:sysadmin-inq
ID: 39272900
I've learned that the runas command can't be used to elevate cmd

0
 
LVL 79

Expert Comment

by:David Johnson, CD, MVP
ID: 39272956
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.
0
 

Accepted Solution

by:
sysadmin-inq earned 0 total points
ID: 39272998
0
 

Author Closing Comment

by:sysadmin-inq
ID: 39303693
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
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to resolve user quota error? 13 65
extended monitor print screen 8 32
Shutdown Inactive Server- Script 4 18
32bit v 64bit processes and impact on memory 7 39
Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
When you try to extract and to view the contents of a Microsoft Update Standalone Package (MSU) for Windows Vista, you cannot extract the files from the MSU. Here we are going to explain how to extract those hotfix details without using any third pa…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question