How do I open a elevated command prompt using command lines on a normal cmd?
For example, I use runas /username:admin cmd
but the cmd that was opened do
While both solutions provided by Dheeraj Bhaskar work, unfortunately they will result in the UAC dialog showing up on top (z-order-wise) but not getting focused (the focused window is the caller cmd/powershell window), thus I either need to grab the mouse and click "yes", or to select the UAC window using Alt+Shift+Tab. (Tested on Win10x64 v1607 build14393.447; UAC = "[...] do not dim [...]".)
The following solution is a bit awkward as it uses two files, but it preserves the correct focus order, so no extra mouse / keyboard actions are required (besides confirming the UAC dialog: Alt+Y).
%SystemRoot%\System32\cmd.exe /k "cd /d"
@start cmdadm.lnk %cd%
Run with su
.