Sign in to follow this  
Followers 0
PC.Guru.01

IF, Else Issue with RunAsSet...

11 posts in this topic

#1 ·  Posted (edited)

Hello...

I am trying to install an application as the "LocalAdmin" account on our workstations but since the XP Upgrade, we have a MIXED environment of 2 localadmin passwords. One was the Win2K Password & now the new format for XP to meet the XP credentials.

For some reason, I can't seem to get my script to work properly. If the 1st password is correct, then it will continue forward. However, if it fails on the 1st login, it seems to NOT go to the next password. It looks fine and I have tried debugging but no errors.

Could someone look at my code and see what I am missing?

; Login to Local Administrator Account but if it fails on the 1st password(OLD Win2K Password), it will try the 2nd password (NEW XP Password)
Opt("RunErrorsFatal", 1)     ; 1=fatal, 0=silent set @error 
RunAsSet("localadmin",@ComputerName,"Win2KPass")
  If @error Then
  RunAsSet("localadmin",@ComputerName,"XPPass")
  Exit
EndIf

This has been driving me crazy...

Edited by Lori Wood

Share this post


Link to post
Share on other sites



Why did you post this FIVE times?!

Share this post


Link to post
Share on other sites

Why did you post this FIVE times?!

I didn't, I just edited my post to correct the script

Share this post


Link to post
Share on other sites

Hello...

I am trying to install an application as the "LocalAdmin" account on our workstations but since the XP Upgrade, we have a MIXED environment of 2 localadmin passwords. One was the Win2K Password & now the new format for XP to meet the XP credentials.

For some reason, I can't seem to get my script to work properly. If the 1st password is correct, then it will continue forward. However, if it fails on the 1st login, it seems to NOT go to the next password. It looks fine and I have tried debugging but no errors.

Could someone look at my code and see what I am missing?

; Login to Local Administrator Account but if it fails on the 1st password(OLD Win2K Password), it will try the 2nd password (NEW XP Password)
Opt("RunErrorsFatal", 1)    ; 1=fatal, 0=silent set @error 
RunAsSet("localadmin",@ComputerName,"Win2KPass")
  If @error Then
  RunAsSet("localadmin",@ComputerName,"XPPass")
  Exit
EndIf

This has been driving me crazy...

If it's proceeding to the second user/password set, you're exiting immediately instead of progressing to the rest of the script...

If @error Then

RunAsSet("localadmin",@ComputerName,"XPPass")

Exit

EndIf


- MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Srry wrong one

Edited by Erik.

I little problem, hard to find and fix

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Hello...

I am trying to install an application as the "LocalAdmin" account on our workstations but since the XP Upgrade, we have a MIXED environment of 2 localadmin passwords. One was the Win2K Password & now the new format for XP to meet the XP credentials.

For some reason, I can't seem to get my script to work properly. If the 1st password is correct, then it will continue forward. However, if it fails on the 1st login, it seems to NOT go to the next password. It looks fine and I have tried debugging but no errors.

Could someone look at my code and see what I am missing?

; Login to Local Administrator Account but if it fails on the 1st password(OLD Win2K Password), it will try the 2nd password (NEW XP Password)
Opt("RunErrorsFatal", 1); 1=fatal, 0=silent set @error 
RunAsSet("localadmin",@ComputerName,"Win2KPass")
  If @error Then
  RunAsSet("localadmin",@ComputerName,"XPPass")
  Exit
EndIf

This has been driving me crazy...

RunAsSet() will not login nor check the credentials if they are correct.

You need to use RunWait() to validate that.

Jos

Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

If it's proceeding to the second user/password set, you're exiting immediately instead of progressing to the rest of the script...

If @error Then

RunAsSet("localadmin",@ComputerName,"XPPass")

Exit

EndIf

I appreciate the quick response on this. I tried moving the EXIT to the end of the script but I am still getting the following error:

CitrixClientInstall_test.au3 (10) : ==> Unable to execute the external program.: 
Run(@TempDir & "\ICAWeb32T.exe /s",@TempDir) 
Logon failure: unknown user name or bad password.
Here is a copy of my full code:

;Login to Local Administrator Account but if it fails on the 1st password(OLD Win2K Password), it will try the 2nd password (NEW XP Password)
Opt("RunErrorsFatal", 1)       ;1=fatal, 0=silent set @error
 RunAsSet("localadmin",@ComputerName,"Win2KPass")
If @error Then
    RunAsSet("localadmin",@ComputerName,"XPPass")
EndIf

;Download Citrix Web Client from the web and saves it to the C Drive
If InetGet("http://na.hmcs.gm.com/Citrix/ICAWEB/en/ica32/ica32t.exe", @TempDir & "\ICAWeb32T.exe",1) then 
    Run(@TempDir & "\ICAWeb32T.exe /s",@TempDir)
Else
MsgBox(0,"","Download Failed")
EndIf

Exit

; Install Citrix Web Client
WinWaitActive("Citrix ICA Web Client")
Send("{Enter}")
WinWaitActive("Citrix License Agreement")
Send("{Enter}")
WinWaitActive("Citrix ICA Web Client")
Send("{Enter}")

Share this post


Link to post
Share on other sites

RunAsSet() will not login nor check the credentials if they are correct.

You need to use RunWait() to validate that.

Jos

So, are you trying to tell me I can't use the RunAsSet within an If statement? I just want to try login with one or the other, that is it. the rest of my script work perfect, just got to get past this password issue.

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Your If statement is fine, but you should be checking for @error in that second RunAsSet()

Edited by weaponx

Share this post


Link to post
Share on other sites

So, are you trying to tell me I can't use the RunAsSet within an If statement? I just want to try login with one or the other, that is it. the rest of my script work perfect, just got to get past this password issue.

Nope , what I am telling you is that you need to do a RunWait() to test if the password is valid.

Example:

;Login to Local Administrator Account but if it fails on the 1st password(OLD Win2K Password), it will try the 2nd password (NEW XP Password)
Opt("RunErrorsFatal", 0)      ;1=fatal, 0=silent set @error
RunAsSet("localadmin",@ComputerName,"Win2KPass")
$RC = RunWait(@ComSpec & " /c dir qq " , @Tempdir, @SW_HIDE)
If @error Then
    MsgBox(0,"First wrong","First wrong")
    RunAsSet("localadmin",@ComputerName,"XPPass")
    $RC = RunWait(@ComSpec & " /c dir qq " , @Tempdir, @SW_HIDE)
    If @error Then
        MsgBox(0,"both wrong","both wrong")
        Exit
    EndIf
EndIf

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

JdeB

That was the magically missing code!

You are awesome...

Thanks so much for your assistance!

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