Sign in to follow this  
Followers 0
RDoes

Strange behavor RunAsSet()

2 posts in this topic

Hi There,

I have a problem with the RunAsSet() function.

When I make a script like the one below it runs fine as long I run it directly from a local drive.

As soon I place this script on a network share it fails.

I can not logon any more the @Error is always set to 1

I run this script on a Windows 2003 domain

Any Idea ?

Thanks.

Opt("ExpandEnvStrings", 0)   ;0=don't expand    , 1=do expand
Opt("MustDeclareVars", 0)     ;0=no                     , 1=require pre-declare
Opt("RunErrorsFatal", 0)       ;1=fatal             , 0=silent set @error
Opt("TrayIconDebug", 0)     ;0=no info          , 1=debug line info
Opt("TrayIconHide", 0)       ;0=show                    , 1=hide tray icon

;****************************************************************************
; Enter Credentials.
; Exit when cancel is pressed.
;****************************************************************************
 $User = Inputbox("Enter account value's 1/3", "User Name.", "")
 If $User = "" then
    Exit
 EndIf
 
 $Password = Inputbox("Enter account value's 2/3", "Password.", "")
 If $Password = "" then
    Exit
 EndIf

 $Domain = Inputbox("Enter account value's 3/3", "Domain.", "")

 
;****************************************************************************
; Set RunAs credentials.
;****************************************************************************
 RunAsSet($User, $Domain, $Password)

 
;****************************************************************************
; Test the credentials.
; If the credentials are not OK then the runwait failed to execute properly.
;****************************************************************************
 RunWait(@ComSpec & " /k exit","",@SW_HIDE) 
  $LoginOk = @Error

   
;****************************************************************************
;Finally display the result to me.
;****************************************************************************
 If $LoginOk <> 0 then
   MsgBox(16, "Error Logon", "Unable to logon. " & $LoginOk)
 Else
   MsgBox(64, "Logon...", "Succesfully loged on " & $LoginOk)
 EndIf

Share this post


Link to post
Share on other sites



Hi,

Indeed it fails because when using the credentials from another user the shares are not there.........

In othere words running from a mapped drive does not work.

Running it from an UNC path works fine.

Andre


What about Windows without using AutoIt ?It would be the same as driving a car without an steering Wheel!

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