Jump to content

Adlibenable Broken?


Guest Hornet
 Share

Recommended Posts

Guest Hornet

I am creating a script to add a PC's to the domain.

I'm trying to do some error handling but am running into a snag.

This code below I put into its own file and it runs with no problem and works like a charm.

adlibenable("adderror",250)
;msgbox(4,"marker1","")

func adderror()
    if WinExists("Network Identification", "The account already exists") then
  send("{ENTER}")
  MsgBox(4096," ", "That name already exists on the PDC, Remove the computer account and try again")
  
    endif
    
    if winexists("Network Identification", "Logon failure:") then
  send("{ENTER}")
  msgbox(4096," ", "You used an invaild username or password")
    endif
endfunc
msgbox(4,"marker2","")

Now this is the script, almost complete.

The same code from above will not work, it never catches the errors?

I'm hoping one of you can point me into the right direction.

; Created by Erik Mathis
; 3/04  Version .1a


Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")


adlibenable("adderror")

; What Domain to use?
;
$domain="aguatl"
$cdomain = MsgBox(4, "Domain ",$domain)
if $cdomain == 7 then 
    $domain=InputBox("Enter Domain Name", " ")
endif
if @error == 1 then exit

;Get The Users Username
;
$uname=InputBox("Enter in Username", "Give the Users Username")
if @error == 1 then exit

;Get the Admin Username and pass
;
$uadmin = inputbox ("Getting Admin username", "Give me an Admin Account",)
if @error == 1 then exit

$padmin =inputbox ("Getting Admin Pass", "Give me the password", "","X")
if @error == 1 then exit
$2padmin = inputbox ("Password again", "Give me the password one more time","","x")
if $padmin <> $2padmin then
    MsgBox(4096," ", "Passwords do not match, sorry")
    exit
endif
    

;Right Click on My Computer and do properties, then the network ID tab, then properties
;
MouseMove (40,100)
MouseClick("right")
send ("r")
WinWaitActive("System Properties")
send("{RIGHT}")
send("!r")

;Get make PC name the username and add to domain
;
send("!c")
send($uname)
send("!d")
send("{TAB}")
send($domain)
send("{ENTER}")


;admin acount to add to domain.
;
WinWaitActive("Domain Username And Password")
send ($domain)
sleep(250)
send ("\")
sleep(250)
send ($uadmin)
sleep(250)
send ("{TAB}")
sleep(250)
send ($padmin)
sleep(250)
send ("{ENTER}")
sleep(250)


;Custom Functions
;
Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc

Func Terminate()
    Exit 0
EndFunc

Func adderror()

    if WinExists("Network Identification", "The account already exists") then
  send("{ENTER}")
  MsgBox(4096," ", "That name already exists on the PDC, Remove the computer account and try again")
  
    endif
    
    if winexists("Network Identification", "Logon failure:") then
  send("{ENTER}")
  msgbox(4096," ", "You used an invaild username or password")
    endif
ENDFUNC
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...