#NoTrayIcon
; PARAMETER
; _RunAs /user:USERNAME "command" /password:PASSWORD [/HIDE] [/WAIT]
If $CmdLine[0] > 2 Then
$Username = StringSplit ( $CmdLine[1], ":")
If $Username[1] = "/user" Then
$Username = $Username[2]
Else
_help()
EndIf
$Domain = StringSplit ( $Username, "\")
If @error Then
$Domain = @ComputerName
Else
$Username = $Domain[2]
$Domain = $Domain[1]
EndIf
$CMD = $CmdLine[2]
$Password = StringSplit ( $CmdLine[3], ":")
If $Password[1] = "/password" Then
$Password = $Password[2]
Else
_help()
EndIf
Else
_help()
EndIf
If $CmdLine[0] > 3 Then
If $CmdLine[4] = "/HIDE" Then
$Window = @SW_HIDE
Else
$Window = @SW_MAXIMIZE
EndIf
Else
$Window = @SW_MAXIMIZE
EndIf
If $CmdLine[0] < 5 Then
$WAIT = "/NOWAIT"
Else
$WAIT = $CmdLine[5]
EndIf
If $WAIT = "/WAIT" Then
RunAsWait($Username, $Domain, $Password, 0, $CMD, @TempDir,$Window)
Else
RunAs($Username, $Domain, $Password, 0, $CMD, @TempDir,$Window)
EndIf
exit 0
Func _help()
MsgBox(64,'Help','_RunAs.exe /user:USERNAME "command" /password:PASSWORD [/HIDE] [/WAIT]' & @CRLF & @CRLF & '<USERNAME> should be in form USER or DOMAIN\USER.')
Exit
EndFunc