title: HTA (vbscript) code + join domain options
body: <p>I have an hta that lets me name a computer during sysprep and adds it to the domain automatically (much of the code i borrowed from someone else on the web). however, i would like to modify it so that it has the follwing:
  code here: <a href="http://pastebin.com/NQm1sn0f" rel="nofollow">http://pastebin.com/NQm1sn0f</a></p>
  
  <p>there will be a field called "network" . when network "A" is chosen, i would like it to set this variables to a predefined value : </p>
  
  <pre><code>domainName = DomainNameArea.Value
  userName = UserNameArea.Value
  domainAdminPass = PasswordArea.Value
  domainAdminPassConfirm = PasswordAreaConfirm.Value
  OUName = OUNameArea.Value
  </code></pre>
  
  <p>basically.. if they chose network A, i would set the domainName = "home.local", UserName ="joinaccount" , domainAdminPass = "password", OUName = "OU=workstations,DC=home,DC=Local"</p>
  
  <p>if they chose network B, i would have different settings of course..</p>
  
  <p>can someone please help me do this ?
  i'll post code here in case the link is not approved or dead:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Computer Deployment&lt;/title&gt;
  &lt;HTA:APPLICATION 
   ID="objCompDeploy" 
   APPLICATIONNAME="Computer Deployment"
   SCROLL="no"
   SINGLEINSTANCE="yes"
   maximizeButton="no"
   minimizeButton="no"
   sysMenu="no"
  &gt;
  &lt;/head&gt;
  &lt;SCRIPT LANGUAGE="VBScript"&gt;
  
  Set WshShell = CreateObject("Wscript.Shell")
  
  Sub modUnattend
  
  run_button.Disabled = True
  
  Set fso = CreateObject("Scripting.FileSystemObject")
  
  base = Wshshell.ExpandEnvironmentStrings("%SystemRoot%")
  unattendFile = base &amp; "\Panther\unattend.xml"
  
  
  computerName = ComputerNameArea.Value
  domainName = DomainNameArea.Value
  userName = UserNameArea.Value
  domainAdminPass = PasswordArea.Value
  domainAdminPassConfirm = PasswordAreaConfirm.Value
  OUName = OUNameArea.Value
  
  if not domainAdminPass = domainAdminPassConfirm then
  msgbox("The passwords do not match.")
  run_button.Disabled = False
  exit sub
  end if
  
  Set xmlDoc = CreateObject("Microsoft.XMLDOM")
  xmlDoc.load unattendFile
  
  'Iterate through Unattend.xml searching for nodes and properties to replace
  Set oNodes = xmlDoc.documentElement.selectNodes("/unattend/settings/component/ComputerName")
  For each n in oNodes
  n.text = computerName
  xmlDoc.save unattendFile
  Next
  
  Set oNodes = xmlDoc.documentElement.selectNodes    ("/unattend/settings/component/Identification/Credentials/Domain")
  For each n in oNodes
  n.text = domainName
  xmlDoc.save unattendFile
  Next
  
  Set oNodes = xmlDoc.documentElement.selectNodes    ("/unattend/settings/component/Identification/Credentials/Password")
  For each n in oNodes
  n.text = domainAdminPass
  xmlDoc.save unattendFile
  Next
  
  Set oNodes = xmlDoc.documentElement.selectNodes    ("/unattend/settings/component/Identification/Credentials/Username")
  For each n in oNodes
  n.text = userName
  xmlDoc.save unattendFile
  Next
  
  Set oNodes = xmlDoc.documentElement.selectNodes("/unattend/settings/component/Identification/JoinDomain")
  For each n in oNodes
  n.text = domainName
  xmlDoc.save unattendFile
  Next
  
  Set oNodes = xmlDoc.documentElement.selectNodes("/unattend/settings/component/Identification/MachineObjectOU")
  For each n in oNodes
  n.text = OUName
  xmlDoc.save unattendFile
  Next
  
  'launch the continuation of setup in a hidden window and wait for return
  'if we dont wait, closing mshta, closes windeploy.exe
  WshShell.Run "%WINDIR%\System32\oobe\windeploy.exe", 0, True
  idTimer = window.setTimeout("closeHTA", 5000, "VBScript")
  End Sub
  
  Sub closeHTA
  window.close
  End Sub
  
  Sub commandLine
  WshShell.Run "%WINDIR%\System32\cmd.exe", 1, True
  End Sub
  
  &lt;/SCRIPT&gt;
  &lt;body&gt;
  &lt;table border="0"&gt;
  &lt;tr&gt;
  &lt;td&gt;Computer Name:&lt;/td&gt;
  &lt;td&gt;&lt;input type="text" name="ComputerNameArea" size="30" maxlength="15" value="computer"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;Domain Name:&lt;/td&gt;
  &lt;td&gt;&lt;input type="text" name="DomainNameArea" size="30" value="domain.local"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;Container OU:&lt;/td&gt;
  &lt;td&gt;
  &lt;select size="1" name="OUNameArea"&gt;
  &lt;option value="OU=someou,DC=domain,DC=local"&gt;Desktops&lt;/option&gt;
  &lt;option value="OU=someotherou,DC=domain,DC=local"&gt;Laptops&lt;/option&gt;
  &lt;/select&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;User Name:&lt;/td&gt;
  &lt;td&gt;&lt;input type="text" name="UserNameArea" size="30"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;Password:&lt;/td&gt;
  &lt;td&gt;&lt;input type="password" name="PasswordArea" size="30"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;Confirm Password:&lt;/td&gt;
  &lt;td&gt;&lt;input type="password" name="PasswordAreaConfirm" size="30"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt; 
  &lt;p align="right"&gt;
  &lt;input id=runbutton  class="button" type="button" value="Continue" name="run_button" onClick="modUnattend"&gt;
  &lt;p align="center"&gt;
  Note: The following characters are invalid for use in the computer name: "  `~!@#$%^&amp;&lt;span     onClick="commandLine"&gt;*&lt;/span&gt;()=+[]{}\|;:'",&lt;&gt;/?.  "
  You will not recieve any warning regarding incorrectly supplied parameters during setup. If any of them are     incorrect, setup completion 
  may take a long time.
  &lt;/body&gt;
  </code></pre>