Sign in to follow this  
Followers 0
njdev1k

Run Netdom From autoit script

5 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



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:


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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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

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

Share this post


Link to post
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!!!!

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