Sign in to follow this  
Followers 0
sshrum

HELP! Run() generating errors

6 posts in this topic

#1 ·  Posted (edited)

I'm trying to run a program as local admin from a compiled AutoIT script (here's the script):

$command = "h:\apps\gx260bios\setup.exe /s /v /p"
$user = "Administrator"
$pass = "adminpass"
$domain = @ComputerName
;===========
If Not IsAdmin() Then 
    if RunAsSet($user, $domain, $pass, 0) = 0 then 
        msgbox(0,@ScriptName,"OS doesn't support running as another user")
        Exit
    EndIf
EndIf
Run($command, "c:\")
RunAsSet()

I've tried a number of variations (the above is the latest).

RunAs Set appears to work as it is *not* returning 0 (fail) otherwise msgbox.

The account credentials I am using are correct as I can log into the box with them. I can run the compiled script fine logged in as a user with admin rights so as far as I can tell that part is working fine. It's just when the script is run under a user account without admin privs that I'm getting back an AutoIT error on the RUN line that indicates that something to the effect of:

"invalid username or bad password"

What am I missing or doing wrong???

OS of target machine=Win2K Pro

OS of my machine=WinXP Pro

AutoIT= 3.1.1 and 3.1.1.75 beta

Edited by sshrum

Sean Shrum :: http://www.shrum.net

All my published AU3-based apps and utilities

'Make it idiot-proof, and someone will make a better idiot'

 

Share this post


Link to post
Share on other sites



According to the help file, RunAsSet() returns 1 regardless of success or failure:

Return Value

  • Returns 1--regardless of success. (If the login information was invalid, subsequent Run/RunWait commands will fail....)
  • Returns 0 if the operating system does not support this function.
Also:

The "Secondary Logon service" or "RunAs service" must not be disabled if you want this function to work.

Share this post


Link to post
Share on other sites

Also, you may want to turn off RunErrorsFatal so your script can handle any failures.

Opt("RunErrorsFatal", 0) ;1=fatal, 0=silent set @error


[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

According to the help file, RunAsSet() returns 1 regardless of success or failure:

Also:

only for Win 95/98/ME, as there exists no real user concept!

From Help file:

Remarks

This function will always return 1 under Window 95/98/Me.

Cheers

Kurt

What am I missing or doing wrong???

Two questions that might solve your problem...

1.) Is h:\ a local drive or a network file share?

2.) Is Administrator your local account or domain account?

Cheers

Kurt

Edited by /dev/null

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

1) H: is a network share

2) Admin is local account

Hmmm...you might have something there.

While the domain user has access to the H: drive but no install privs, the local admin account has privs to install but *may not have* access privs to the H: domain network drive. I'll need to test that on Monday.

Edited by sshrum

Sean Shrum :: http://www.shrum.net

All my published AU3-based apps and utilities

'Make it idiot-proof, and someone will make a better idiot'

 

Share this post


Link to post
Share on other sites

While the domain user has access to the H: drive but no install privs, the local admin account has privs to install but *may not have* access privs to the H: domain network drive. I'll need to test that on Monday.

I guess, that's exactly your problem.

Cheers

Kurt


__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

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