Monday, February 06, 2012
   
Text Size

XP - Add PC to Domain 2

 MyTest = (chr(34) & "c:\winnt\system32\netdom.exe" & chr(34) & " " & "JOIN" & " " & lcase(compn) & " " & "/d:" & chr(34) & "ah.andrew-henderson.me.uk" & chr(34) & " " & "/OU:" & chr(34) & "OU=" & lcase(varOU) & chr(34) & ",OU=" & varDirectorate & ",DC=ANDREW-HENDERSON,DC=ME,DC=UK" & " " & "/UD:AH\" & lcase(varuserid) & " " & "/PD:" & lcase(varPassword) & " " & chr(62) & " c:\build.txt")

 Set OFILES = FSO.OPENTEXTFILE ("c:\update.bat",2,True)
  OFILES.WRITE (MyTest)
 OFILES.Close

 WshShell.Run ("c:\update.bat"),, True

 On Error Resume Next
 Set OFILES = FSO.OPENTEXTFILE ("c:\build.txt", 1, True)
  ReadLineTextFile1 = OFiles.Readline
  OFILES.SkipLine
  ReadLineTextFile2 = OFiles.ReadLine

 ReadLine1 = Left(ReadLineTextFile1, 27)

 If FSO.FileExists ("c:\update.bat") Then
  WshShell.Run (kAttrib & " " & chr(34) & "C:\update.bat" & chr(34) & " " & "-r" & " " & "-a" & " " & "-s" & " " & "-h"),, True
  FSO.DeleteFolder ("C:\update.bat"), True
 Else
 End If

 If lcase(ReadLine1) = lcase("the command completed succe") Then
  MSGBOX ("The PC Has Been Successfully Added to The Domain")
  Added_Dom = "Yes"
 Else
 End If

 If lcase(ReadLine1) = lcase("the parameter is incorrect.") Then
  MSGBOX ("There was a problem, incorrect parameters have been processed.  Please re-run the script and Check you ID and Password are correct.")
  Added_Dom = "No"
 Else
 End If

 If lcase(ReadLine1) = lcase("this machine is already joi") Then
  MSGBOX ("This Machine is Already a Member of the Domain, please remove From the Domain and re-run this script")
  Added_Dom = "No"
 Else
 End If

 If lcase(ReadLine1) = lcase("the account already exists.") Then
  MSGBOX ("An Account For This Machine already exists in the Domain, Please Remove the Account and re-run this script.")
  Added_Dom = "No"
 Else
 End If

 If lcase(ReadLine1) = lcase("logon failure: unknown user") Then
  MSGBOX ("You have entered an Invalid User Name or Password")
  Added_Dom = "No"
 Else
 End If

 If Lcase(ReadLine1) = lcase("The Referenced account is c") Then
  MSGBOX ("The Referenced Account used is currently Locked Out, Please Unlock the Account.")
  Added_Dom = "No"
 Else
 End If