LuI Posted July 4, 2012 Share Posted July 4, 2012 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 Link to comment Share on other sites More sharing options...
UEZ Posted July 4, 2012 Share Posted July 4, 2012 (edited) 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 Edited July 4, 2012 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
johnmcloud Posted July 4, 2012 Share Posted July 4, 2012 (edited) RUN() Return ValueSuccess: The PID of the process that was launched. Failure: Returns 0 and sets @error to non-zeroPost the script Edited July 4, 2012 by johnmcloud Link to comment Share on other sites More sharing options...
LuI Posted July 4, 2012 Author Share Posted July 4, 2012 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 = 0If $AsAdmin Then $PID = RunAs($usr, $usr, $Domn, 4, $Shl&$Cmd, _ $Path, $Shw, 0x3) ; Call a console ; Call a console as admin $MyError=@errorElse $PID = Run($Shl&$Cmd, $Path, $Shw, 0x3) ; Call a console as user $MyError=@errorEndIf Link to comment Share on other sites More sharing options...
UEZ Posted July 4, 2012 Share Posted July 4, 2012 Try this $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 Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
LuI Posted July 4, 2012 Author Share Posted July 4, 2012 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 ;-) Link to comment Share on other sites More sharing options...
LuI Posted July 4, 2012 Author Share Posted July 4, 2012 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 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now