Can anyone point me to the error codes of RunAs or Run?
Started by
LuI
, Jul 04 2012 01:22 PM
6 replies to this topic
#1
Posted 04 July 2012 - 01:22 PM
Hi all,
sorry for that Q, but I cant find my solution :-((
I try to call a console program using Run() or RunAs(), but I get a PID=0 and @error=1. Error codes are not explained in the help. Can someone help out?
TIA
--
Greetings from Germany!
Uwe
sorry for that Q, but I cant find my solution :-((
I try to call a console program using Run() or RunAs(), but I get a PID=0 and @error=1. Error codes are not explained in the help. Can someone help out?
TIA
--
Greetings from Germany!
Uwe
#2
Posted 04 July 2012 - 01:24 PM
Hi Doc,
can you show your code please?
Otherwise we can assume only what might be wrong.
PID=0 means the run command was not successfull.
Br,
UEZ
can you show your code please?
Otherwise we can assume only what might be wrong.
PID=0 means the run command was not successfull.
Br,
UEZ
Edited by UEZ, 04 July 2012 - 01:26 PM.
The own fart smells best! ✌
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯
#3
Posted 04 July 2012 - 01:24 PM
RUN() Return Value
Success: The PID of the process that was launched.
Failure: Returns 0 and sets @error to non-zero
Post the script
Success: The PID of the process that was launched.
Failure: Returns 0 and sets @error to non-zero
Post the script
Edited by johnmcloud, 04 July 2012 - 01:25 PM.
#4
Posted 04 July 2012 - 01:31 PM
Sorry guys,
I was more interested in WHAT error 1 means resp. where I can read that.
But here we go:
$Shl = "command /c"
$Cmd = "PGRestaWS"
$usr = "yyy"
$Domn = "xxx"
$Shw = @SW_MINIMIZE
$AsAdmin = 0
If $AsAdmin Then
$PID = RunAs($usr, $usr, $Domn, 4, $Shl&$Cmd, _
$Path, $Shw, 0x3) ; Call a console ; Call a console as admin
$MyError=@error
Else
$PID = Run($Shl&$Cmd, $Path, $Shw, 0x3) ; Call a console as user
$MyError=@error
EndIf
I was more interested in WHAT error 1 means resp. where I can read that.
But here we go:
$Shl = "command /c"
$Cmd = "PGRestaWS"
$usr = "yyy"
$Domn = "xxx"
$Shw = @SW_MINIMIZE
$AsAdmin = 0
If $AsAdmin Then
$PID = RunAs($usr, $usr, $Domn, 4, $Shl&$Cmd, _
$Path, $Shw, 0x3) ; Call a console ; Call a console as admin
$MyError=@error
Else
$PID = Run($Shl&$Cmd, $Path, $Shw, 0x3) ; Call a console as user
$MyError=@error
EndIf
#5
Posted 04 July 2012 - 01:38 PM
Try this
And please use code tags when posting the code
Br,
UEZ
$Shl = @ComSpec & " /c " $Cmd = "PGRestaWS" $usr = "yyy" $Domn = "xxx" $Shw = @SW_MINIMIZE $AsAdmin = 0 $Path = "" If $AsAdmin Then $PID = RunAs($usr, $usr, $Domn, 4, $Shl&$Cmd, _ $Path, $Shw, 0x3) ; Call a console ; Call a console as admin $MyError=@error Else $PID = Run($Shl&$Cmd, $Path, $Shw, 0x3) ; Call a console as user $MyError=@error EndIf
And please use code tags when posting the code
Br,
UEZ
The own fart smells best! ✌
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯
#6
Posted 04 July 2012 - 01:49 PM
UEZ,
thx for your solution.
I assume RunAs() does really need the complete path to cmd; having cmd in the search path is not enough?!
Anyway, do you have a ref to the error codes as being returned by Run() and RunAs()?
I'll try my best with code tags in future. Had been away from here for looong time ;-)
thx for your solution.
I assume RunAs() does really need the complete path to cmd; having cmd in the search path is not enough?!
Anyway, do you have a ref to the error codes as being returned by Run() and RunAs()?
I'll try my best with code tags in future. Had been away from here for looong time ;-)
#7
Posted 04 July 2012 - 02:19 PM
Googling for 'RunAs Error Code 1' returns a lot of links. At least a few made the impression that a fully qualified path is required as the help to RunAs() states.
--
Greetings from Germany!
Uwe
--
Greetings from Germany!
Uwe
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users





