Hi All,
I wrote a function to implement the new runas tool.
Cheers,
Richard
code:
;---------------------------------------------------------------------------------------------------- RunAs
;FUNCTION RunAs($CommandType,$Command,OPTIONAL $Switches)
;ACTION Runs installations as administrator
;SYNTAX RETCODE = RunAs($CommandType,$Command[,$Switches])
;PARAMETERS COMMANDTYPE
; Either SHELL or RUN depending on whether the script waits for the program or not
; COMMAND
; The command to run
; SWITCHES
; Optional switches for the runas.exe.
; /profile if the user's profile needs to be loaded.Default
; /env to Use current environment instead of user's
; /netonly Use If the credentials specified are For remote access only
;RETURN 0 if successful, otherwise error code
;REMARKS none
;DEPENDENCIES none
;EXAMPLE $=RunAs("Run",$Exepath+"\EPO\FramePkg.exe")
Function RunAs($CommandType,$Command,OPTIONAL $Switches)
If InGroup(@WKSTA+"\"+SIDToName("S-1-5-32-544")) OR @INWIN=2
$RunAs=Execute($CommandType+" '"+$Command+"'")
Else
If $Switches<>"" $Switches=$Switches+" " EndIf
If $CommandType="Shell" $Switches=$Switches+"/w " EndIf
$RunAs=Execute($CommandType+" '"+$ExePath+"\Utils\Runas.exe /s "+$Switches+"/user:"+@WKSTA+"\Administrator /pass:"+$AdminPwd+' "'+$Command+'"'+"'")
EndIf
EndFunction