How to run program from command line with elevated rights

There is a way to do this in PowerShell:

PS> Start-Process powershell -Verb runAs

It looks like this utility - Hidden Start - will do what you wish if you use the /uac switch. Here's an example command line:

hstart /UAC "notepad.exe"

This will pop up the UAC dialog rather than ask for a password like runas does.

enter image description here


Building on Rustam's answer, you can:

  • Create a su.bat batch file somewhere in your default %PATH%, with the following content:
@echo off
setlocal
set cmd=%*
if not defined cmd set cmd=%ComSpec%
powershell iex """start -v runas $Env:cmd"""
  • Add this function to your PowerShell $profile : function su {start -verb runas @args}

Now you can issue su <command> [parameters] in either shell !