Jump to content

Run Netdom From autoit script


Recommended Posts

Is there a way to run Netdom to join a machine to a domain through autoit? I have tried the below script and also rewritten the command for netdom a few times.

Dim $username, $passwd

$bLoop = 1

While $bLoop = 1

$username = InputBox("Username", "Please enter your username and click OK", "Ex. johndo", "")

If @error = 1 Then

MsgBox(4096, "Error", "You pressed 'Cancel' - try again!")

Else

If $username = "" Then

MsgBox(4096, "Error", "You must enter your username")

Else

$bLoop = 0

EndIf

EndIf

WEnd

$bLoop = 1

While $bLoop = 1

$passwd = InputBox("Password", "Please enter your password and click OK", "", "*")

If @error = 1 Then

MsgBox(4096, "Error", "You pressed 'Cancel' - try again!")

Else

If $passwd = "" Then

MsgBox(4096, "Error", "You must enter your password")

Else

$bLoop = 0

EndIf

EndIf

WEnd

$bLoop = 1

While $bLoop = 1

$computeramt = InputBox("Computer", "Please enter what number computer this is Ex. If this is your Only computer leave 01 and hit OK", "01", "")

If @error = 1 Then

MsgBox(4096, "Error", "You pressed 'Cancel' - try again!")

Else

If $computeramt = "" Then

MsgBox(4096, "Error", "You must enter a number")

Else

$bLoop = 0

EndIf

EndIf

WEnd

RunWait("C:\Netdom.exe JOIN COMPUTERNAME /DOMAIN:domainname /UserD:$username /PasswordD:$passwd","",@SW_HIDE)

Edited by njdev1k
Link to comment
Share on other sites

  • Developers

Is there a way to run Netdom to join a machine to a domain through autoit? I have tried the below script and also rewritten the command for netdom a few times.

<{POST_SNAPBACK}>

Try:

RunWait(@comspec & " /c  c:\Netdom.exe JOIN COMPUTERNAME /DOMAIN:domainname /UserD:" & $username & " /PasswordD:" & $passwd ,"",@SW_HIDE)

Are you sure about the location of Netdom.exe ?

:ph34r:

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

Try:

RunWait(@comspec & " /c  c:\Netdom.exe JOIN COMPUTERNAME /DOMAIN:domainname /UserD:" & $username & " /PasswordD:" & $passwd ,"",@SW_HIDE)

Are you sure about the location of Netdom.exe ?

:ph34r:

<{POST_SNAPBACK}>

Yes I'm sure Netdom is in that location, the command you provided did not work. Thanks for trying.
Link to comment
Share on other sites

  • Developers

Try running it with the /K in stead of /c and remove the @SW_HIDE just to see what the reason for failure is...

RunWait(@comspec & " /k  c:\Netdom.exe JOIN COMPUTERNAME /DOMAIN:domainname /UserD:" & $username & " /PasswordD:" & $passwd )

:ph34r:

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

OK problem solved. I moved the netdom.exe to C:\Windows\System32 and then ran

RunWait(@comspec & " /k Netdom.exe JOIN COMPUTERNAME /DOMAIN:domainname /UserD:" & $username & " /PasswordD:" & $passwd )

I took out the C:\ before netdom.exe

Thank you for your help, you rock JdeB!!!!

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...