C:\>runas /env /user:administrator "cmd /t:2f /k net localgroup Administrators /add %USERDOMAIN%\%USERNAME% && pause"
You'll need the local admin password, obviously, or use /user:DOMAIN\administrator or another admin user.
The /t:2f (optional) sets the background to green so you know it's an elevated prompt. The /env stays in the current user's environment, otherwise the %USERNAME% variable would expand to "Administrator"
Also, your current directory must be on a local drive accessible to Admin, or else you'll get a "Directory name is invalid" error.
No comments:
Post a Comment