您的位置:首页 > 其它

how to run program as administrator in cmd

2016-01-27 00:00 519 查看
As stated here http://msdn.microsoft.com/en-us/library/bb756922.aspx "runas" can't be used to run a command line with elevated privileges .

runas /showtrustlevels and /trustlevel seems to be, at best, a Microsoft "work in progress"...completly useless IMHO

Extract from http://msdn.microsoft.com/en-us/library/bb756922.aspx :
../..
Do Not Use Runas to Launch an Elevated Process
The Run as… option from Windows XP and Windows Server 2003 has been replaced withRun as administrator on the context menu (available when you right-click an executable) in Windows Vista. When a standard user selects theRun as administrator option, the user is presented with a list of active administrators on the local computer. Standard users with higher privileges, such as members of the Backup Operators group, are also displayed. When an administrator selects the Run as administrator option, a User Account Control dialog box immediately prompts the user to continue before running the application.
Users must use the runas command at the command prompt in order to run an application as another user.

Important
Be aware that runas does not provide the ability to launch an application with an elevated access token, regardless of whether it is a standard user with privileges like a Backup Operator or an administrator. The runas command grants the user the ability to launch an application with different credentials. The best method to use to launch an application with a different account is to perform the action programmatically by using a service and not rely on the user to run the component as a different user. If your program programmatically uses the runas command, ensure that it is not intended to launch an elevated process.
../..

Instead, use the "Elevation Powertoys" : http://technet.microsoft.com/en-us/magazine/2008.06.elevation.aspx,
(maybe a updated version here :
http://blogs.technet.com/b/deploymentguys/archive/2009/01/21/the-elevation-powertoys-and-windows-7.aspx ?)

"UAC confirmation" will always pop-up (if your UAC parameters don't disable it)

Hope this help

jean-marc haby
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: