Link to home
Start Free TrialLog in
Avatar of JeffBeall
JeffBeallFlag for United States of America

asked on

Vista command shell

I guess Im late coming to the party, but I just noticed in Vista that the command shell needs to be Run as& administrator to do things like ipconfig /release. Is there a switch to Run as& the administrator, so in the run window I could type cmd /some switch?
Avatar of JeffBeall
JeffBeall
Flag of United States of America image

ASKER

By the way, I found how to make a shortcut to run cmd as administrator, but I was hoping there is a command line switch.
SOLUTION
Avatar of Brian Pierce
Brian Pierce
Flag of United Kingdom of Great Britain and Northern Ireland 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
SOLUTION
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
SOLUTION
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
ASKER CERTIFIED SOLUTION
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
I believe I may have mis-interpreted your requirements.  To evelate from the command prompt, I use a tool written by John Robbins - www.wintellect.com named elevate.exe -

http://www.wintellect.com/cs/blogs/jrobbins/archive/2007/03/27/elevate-a-process-at-the-command-line-in-vista.aspx

It works sufficiently well but the results of any command tend to disappear immediately unless the command independently holds the console window open itself.  As a result, I don't run elevate.exe directly, instead I use a one line batch file to wrap it such that the elevate command is prefixed with cmd /k, like this -

@elevate.exe %COMSPEC% /k call echo/ ^& cd /d %CD% ^& echo %CD% = %* ^& %*

... I also abbreviate it to UAC.cmd to reduce typing.
I use that also and created a batch file to wrap it named admincmd.bat:

@echo off

setlocal

if "%~1"=="" elevate cmd&goto :EOF

set tempFile=%temp%\_temp.bat

(echo @%*)>"%tempFile%"
(echo @pause)>>"%tempFile%"

elevate "%tempFile%"

del "%tempFile%"

This way you can say:

admincmd

To get a new DOS box that runs with elevated privileges.

Another example is:

admincmd ipconfig /renew

Will run ipconfig with the /renew option using elevated privileges.
Hehe ... great minds as they say :0)

Mine does virtually the same thing I think.  If I type "uac", I get a new elevated shell in the same drive and directory as the one that spawned it that remains open.  If I type "uac ipconfig /flushdns", I get a new elevated shell as above that writes the executed command to the second line and then runs it and remains.  
...adding the place in current directory idea from MSE-dwells ;)