Jump to content

Can anyone point me to the error codes of RunAs or Run?


Recommended Posts

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

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 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

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

Link to comment
Share on other sites

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...