How to Pass Commands to Elevated CMD Shortcut
-
Thursday, January 31, 2013 4:39 PM
I'm trying to run a couple of commands, which need to be run from an elevated CMD prompt.
Right now I've created a shortcut called elevate.lnk and trying to figure out how I could pass commands into the elevated prompt/shortcut. There seems to be a problem because if I try:
start elevated.lnk
REM Commands go here:
CD C:\Windows
REM pause, to see where the commands go.
It will perform the CD on the non elevated cmd window.
Suggestions? Runas isn't an option, as I'm trying to deploy this from the network, and don't care to have credentials saved as plain text.
All Replies
-
Thursday, January 31, 2013 4:45 PMModerator
Hi,
You can't bypass UAC, and this is by design.
Bill
-
Thursday, January 31, 2013 4:48 PM
UAC is turned off for this testing. Or can be auto elevated through our ViewFinity software/policy.
Do you have any suggestions on how I could execute a couple cmd's from an elevated prompt?
-
Thursday, January 31, 2013 4:50 PMModerator
I don't understand the question (?). Open an elevated command window and run the commands or the script that you want to run elevated.
Bill
-
Thursday, January 31, 2013 4:52 PM
The former.
Open an elevated command window, and run some commands.
-
Thursday, January 31, 2013 5:22 PMModerator
The former of what? (Sorry, I don't understand your question.)
Bill
-
Thursday, January 31, 2013 5:31 PMModerator
As an aside: I would strongly discourage disabling UAC. UAC is an important technology in the Windows ecosystem that is helping everyone get away from running every program as an administrator.
Bill
-
Thursday, January 31, 2013 6:45 PM
The former of what? (Sorry, I don't understand your question.)
Bill
"the former" is the first of two options, and "the latter" is the second of two options. As he says, what he wants to do is to "Open an elevated command window, and run some commands (presumably in that elevated command prompt window)".
Still running mostly XP, so am not sure if I am correct on this, however, it is one thing (and easy) to open a command prompt window under alternate credentials by right-clicking and selecting "run as..." or by setting "run with different credentials" in the advanced properties of the shortcut tab. But it is quite a different thing to open a command prompt window from which one can execute privileged commands without being asked via UAC to confirm. If that is what he wants, then he needs to roll back his systems to XP. ;-)
Al Dunbar -- remember to 'mark or propose as answer' or 'vote as helpful' as appropriate.
-
Thursday, January 31, 2013 6:58 PMModerator
Open an elevated command window, and run some commands.
To do that: Simply follow your own instructions (open an elevated window, then run some commands in it).
That's what I don't understand. You're already describing what you want to do (?).
Bill
- Proposed As Answer by Bill_StewartMicrosoft Community Contributor, Moderator Monday, February 04, 2013 10:34 PM
-
Thursday, January 31, 2013 7:01 PM
It is also possible to invoke the batch file from a script. The purpose of the script is to raise a UAC challenge. If the user accepts it then the batch file will run, otherwise it won't.it is one thing (and easy) to open a command prompt window under alternate credentials by right-clicking and selecting "run as..." or by setting "run with different credentials" in the advanced properties of the shortcut tab. But it is quite a different thing to open a command prompt window from which one can execute privileged commands without being asked via UAC to confirm.
-
Thursday, January 31, 2013 7:09 PMModerator
If the purpose is to provoke an elevation prompt from a shell script (batch file), then the elevate32.exe/elevate64.exe can do this as well.
@echo off elevate64 cmd.exe /c scriptname.cmd
In this case elevate64.exe will cause an elevation prompt.
http://www.westmesatech.com/misctools.html
Bill
- Marked As Answer by Bill_StewartMicrosoft Community Contributor, Moderator Tuesday, March 19, 2013 7:07 PM

