#include #include f_RunAsAdmin_CMD(0,1,@SW_SHOW) Func f_RunAsAdmin_CMD($iMethod = 0, $iDebugFlag = 0, $sShowFlag = @SW_SHOW) ; This function returns an administrator CMD window based on the method chosen: ; $iMethod = 0 : use ShellExecute with RunAs ; $iMethod = 1 : use #RequireAdmin and Run("cmd") ; $iMethod = 0 is Default Option Local $sMessage = "Window State: " If Not($iMethod = 1) Then $iMethod = 0 ; Default method EndIf Switch $sShowFlag Case @SW_SHOW $sMessage &= "Visible" Case @SW_HIDE $sMessage &= "Hidden" Case @SW_MINIMIZE $sMessage &= "Minimized" Case @SW_MAXIMIZE $sMessage &= "Maximized" Case Else ; Default $sShowFlag = @SW_SHOW $sMessage &= "Visible" EndSwitch If ($iDebugFlag = 1) Then ConsoleWrite("Method Used: " & String($iMethod) & @LF & $sMessage & @LF) MsgBox(0,"Run CMD as Admin","Method Used: " & String($iMethod) & @LF & $sMessage ,1) EndIf If ($iMethod = 0) Then ShellExecute(@ComSpec, "", "", "RunAs",$sShowFlag) Else #RequireAdmin Run("cmd","",$sShowFlag) EndIf EndFunc