Jump to content
Sign in to follow this  
JerichoJones

RunAs Woes

Recommended Posts

JerichoJones

I am hoping that I am missing something obvious. I cannot get the below code to work. It sure looks right to me but I have been staring at it for about two hours. $CopyINIFile returns 0 and @error returns 0. Shouldn't @error return a non-zero number on failure?

The id, pass, vars are all good.

help!

$CopyINIFile = RunAs("UserID", "Domain", "Password",0, @ComSpec & " /C " & @SystemDir & "\System32\XCOPY.EXE \\" & $SiteServer & "\NetApps$\NTE\BSDNWEA.INI " & CHR(34) & @ScriptDir & CHR(34) & " /Y",@ScriptDir, @SW_HIDE, $STDERR_CHILD)

If StderrRead($CopyINIFile) = 0 Then

MsgBox(16,"BSD TestTaker","Local INI file could NOT be updated." & @CRLF & "Please contact the Service Desk for assistance @302-555-1234" & @CRLF & "Please reference this error during your call. Thanks!")

Exit(1)

EndIf

Share this post


Link to post
Share on other sites
JerichoJones

I am hoping that I am missing something obvious. I cannot get the below code to work. It sure looks right to me but I have been staring at it for about two hours. $CopyINIFile returns 0 and @error returns 0. Shouldn't @error return a non-zero number on failure?

The id, pass, vars are all good.

help!

$CopyINIFile = RunAs("UserID", "Domain", "Password",0, @ComSpec & " /C " & @SystemDir & "\System32\XCOPY.EXE \\" & $SiteServer & "\NetApps$\NTE\BSDNWEA.INI " & CHR(34) & @ScriptDir & CHR(34) & " /Y",@ScriptDir, @SW_HIDE, $STDERR_CHILD)

If StderrRead($CopyINIFile) = 0 Then

MsgBox(16,"BSD TestTaker","Local INI file could NOT be updated." & @CRLF & "Please contact the Service Desk for assistance @302-555-1234" & @CRLF & "Please reference this error during your call. Thanks!")

Exit(1)

EndIf

If I change the working dir to @SystemDir I at least get the cmd prompt to run but nothing happens and it returns nothing. This makes no sense.

Share this post


Link to post
Share on other sites
therks

The user you're trying to run as may not have access to the @ScriptDir folder. That would be my first idea.

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.