Jump to content

Joining a Windows2000/2003 Domain... AutoIt Integration


Recommended Posts

I have been "putzing" around with AutoIT (Beta - Latest) and have decided it would assist me in not only with unassisted software installs, but it could also better serve my clients and myself if I could use command line programs provided for use with Windows (NETDOM.EXE) The program could evolve into something more spectacular, but this is a help forum, so I'll keep my question basic.

What I am looking is a way to script a box which has 4 Input boxes.

1st - For the Computer name: COMPUTERNAMEFIELD.

2nd - Login name (One that will be allowed to join AD/Server): USERACCOUNT FIELD.

3rd - The password for that client: PASSWORDFIELD.

With a Join Button & A Cancel Button (Which of course Exists the program)

I'll be writing my version of it, but it would help if someone had something similar.

The CMD Line options for NETDOM I would like to execute are this:

------------------------

netdom join COMPUTERNAMEFIELD /Domain:DOMAINNAMEHERE /userd:USERACCOUNTFIELD /passwordd:PASSWORDFIELD /reboot:5

------------------------

The Domain Name would be default, since I work with 1 Domain, but I would imagine a dropdown list of sorts through an INI file could be written to accomodate other domains.

So the Input Fields

1. COMPUTERNAMEFIELD

2. USERACCOUNTFIELD

3. PASSWORDFIELD

Any Ideas?

Link to comment
Share on other sites

Any Ideas?

To me, it looks like you already know what you need to do. I suggest you post your code once you get started and ask from help from there unless you want someone else to write it for you.. :P

But, here's some suggestions:

I've used the netdom command along with the _stringencrypt command to hide usernames and passwords in my ini file, look at the the gui bulder in Scite editor, and of course, read the help file. Good luck! I look forward to seeing your progress. :lmao:

Link to comment
Share on other sites

Ok here is the code:

; Domain Join
; 10:27 AM 12/9/2005 - DJ VenGenCe
; Automating the procedure to manually join a domain without having to type as much info
; Commenting Idea "borrowed" from SampleGUI Script included with AutoIT.
; Written in Notepad v5.1

#include <GuiConstants.au3>
; GUI AREA

GuiCreate("NETDOM GUI v.0ßeta", 320, 240)
GuiSetIcon(@SystemDir & "\shell32.dll", 12)

;Context Menu - Not to useful now.  But for future implementation

GUICreate("Test",300,200)
$contextmenu = GuiCtrlCreateContextMenu ()
$aboutitem = GuiCtrlCreateMenuitem ("About",$contextmenu)
GuiCtrlCreateMenuitem ("",$contextmenu); Seperator
$exititem = GuiCtrlCreateMenuitem ("Exit",$contextmenu)

; INPUT AREA
; Computer name Input
GuiCtrlCreateLabel("Computer Name:", 20, 10, 200, 20)
$computername = GuiCtrlCreateInput("", 100, 5, 130, 20)

; Account to Join Domain
GuiCtrlCreateLabel("Login:", 20, 40, 200, 20)
$login = GuiCtrlCreateInput("", 55, 35, 130, 20)

; Password
GuiCtrlCreateLabel("Password:", 20, 70, 200, 20)
$password = GuiCtrlCreateInput("", 70, 65, 130, 20)

; The Join and Cancel Buttons
GuiCtrlCreateButton("Join", 10, 100, 50, 20)
$cancel = GuiCtrlCreateButton("Cancel", 100, 100, 50, 20)

;While and Wend

GuiSetState()

While 1

    $msg = GuiGetMsg()

    If $msg = $exititem Or $msg = -3 Or $msg = -1 or $msg = $cancel Then ExitLoop
    If $msg = $aboutitem Then Msgbox(0,"About","NETDOM - GUI v1.0ßeta")

WEnd

GUIDelete()
Edited by DJ VenGenCe
Link to comment
Share on other sites

yes, wen u put all the input u can use the variables to do a function..for example in this code

$1 = "hello"
$2 = "people"

MsgBox(0, "", $1 & $2)

This would produce a msgbox which would say "hello people"...so wen u use cmdline, just put in all the variables in the commandline functions and it should work...also u need to set a variable to the "join" button and the join button should be the one that starts the whole process of joining...so the answer is: yes u can use the varialbes u assinged to the input fileds in another function...

THIS POST WAS EDITED ONCE

GodandRock leaves his mark. ^*+-._.-+*^(|{[\:=^*+-._ GAR _.-+*^=:/]}*^|)^*+-._.-+*^

Edited by GodandRock

[font="Fixedsys"][size="3"][u][font="Franklin Gothic Medium"] [/font][/u][/size][/font]

Link to comment
Share on other sites

I use a Remote Installation Server with the Client Install Wizard these days...This might be helpful; but untested:

$ComputerName =
$DomainName =
$DomainAdmin =
$Administrator =

RunWait(@ComSpec & " /C NETDOM JOIN " & $ComputerName & " /Domain: " & $DomainName & "  /UserD: " & $DomainAdmin & " /PasswordD:* /UserO: " & $Administator & " /PasswordO:* /reboot:45 ")

If know about Windows API coding you can go this route:

dwError = NetJoinDomain( *szComputerName ? szComputerName : NULL,
                         szDomain,
                         NULL,
                         szUser,
                         szPassword,
                         dwFlags );
if( dwError != NERR_Success )
{
  //handle error
}
else
{
  //success
}
Edited by PerryRaptor
Link to comment
Share on other sites

After trying your looking at this code, would the following return what I need?

$ComputerName = GuiCtrlCreateInput("", 55, 35, 130, 20)
$DomainName = ... etc.
$DomainAdmin = ... etc
$Administrator = ... etc

____________________________________________________________

I use a Remote Installation Server with the Client Install Wizard these days...This might be helpful; but untested:

$ComputerName =
$DomainName =
$DomainAdmin =
$Administrator =

RunWait(@ComSpec & " /C NETDOM JOIN " & $ComputerName & " /Domain: " & $DomainName & "  /UserD: " & $DomainAdmin & " /PasswordD:* /UserO: " & $Administator & " /PasswordO:* /reboot:45 ")

If know about Windows API coding you can go this route:

dwError = NetJoinDomain( *szComputerName ? szComputerName : NULL,
                         szDomain,
                         NULL,
                         szUser,
                         szPassword,
                         dwFlags );
if( dwError != NERR_Success )
{
  //handle error
}
else
{
  //success
}
Link to comment
Share on other sites

Glad to see some code. :P

This should hopefully get you started. Do a search on "From Designer" used to make GUI's.

#include <GuiConstants.au3>
GuiCreate("Join Domain", 386, 218, 490,359)
$edt_uname = GuiCtrlCreateInput("Username", 16, 16, 169, 21)
$edt_pw = GuiCtrlCreateInput("Password", 16, 48, 169, 21)
$edt_domain = GuiCtrlCreateInput("Domain", 16, 80, 169, 21)
$btn_join = GuiCtrlCreateButton("Join Domain", 112, 112, 73, 25)
$GroupBox1 = GuiCtrlCreateGroup("Current Information", 200, 16, 169, 153)
$pc_name = GuiCtrlCreateLabel("", 230, 30, 90, 13)
$pc_ip = GuiCtrlCreateLabel("", 230, 55, 90, 13)
$current_user = GuiCtrlCreateLabel("", 230, 78, 90, 13)
$os = GuiCtrlCreateLabel("", 230, 102, 90, 13)
$Animate1 = GUICtrlCreateAvi  ("shell32.dll",152,88, 120, 16, 16)
GUICtrlSetState($Animate1, 0 )
_UpdateLabels()
GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $btn_join
        $domain = GUICtrlRead($edt_domain)
        $username = GUICtrlRead($edt_uname)
        $password = GUICtrlRead($edt_pw)
    ;edit $cmd below to make sure your command line is passed correctly.
        $cmd = "netdom.exe " & @ComputerName & " /userd:" & $domain & "\" & $username & " /passwordd:" & $password 
        GUICtrlSetState($Animate1, 1)
        MsgBox(32,"Info",$cmd)
    ;RunWait(@ComSpec & " /C " & $cmd,"",@SW_HIDE)
        GUICtrlSetState($Animate1, 0)
    Case Else
    ;;;
    EndSelect
WEnd
Exit

Func _UpdateLabels();update labels here
GUICtrlSetData($pc_name,@ComputerName)
GUICtrlSetData($pc_ip,@IPAddress1)
GUICtrlSetData($current_user,@UserName)
GUICtrlSetData($os,@OSTYPE)
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...