20 March 2013

Powershell: Adding powershell Run-as Administrator Option

For some Powershell scripts, they need the elevated privileges, even when UAC is disabled. In order to do this, there are two options.
  1. Run a cmd.exe session as administrator and execute the PS1 file from the command line.
  2. Add the registry key listed below to be able to right-click on a PS1 file and run-as administrator.
All you need to do is copy the info below to a blank notepad screen and then save it as {Filename}.reg. Double-click on the reg file and the key will be added to the registry, thereby adding the run-as administrator option. Here is the reg key to add the run-as administrator option:

You can download the reg key from here.

 Windows Registry Editor Version 5.00  

 [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\runas\command]  
 @="\"c:\\windows\\system32\\windowspowershell\\v1.0\\powershell.exe\" -noexit \"%1\""  

0 comments:

Post a Comment