Jump to content

IF, Else Issue with RunAsSet...


PC.Guru.01
 Share

Recommended Posts

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
Link to comment
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]

Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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}")
Link to comment
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.

Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...