Advertisement
Guest User

hta code

a guest
Oct 24th, 2013
378
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.86 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>Computer Deployment</title>
  4. <HTA:APPLICATION
  5. ID="objCompDeploy"
  6. APPLICATIONNAME="Computer Deployment"
  7. SCROLL="no"
  8. SINGLEINSTANCE="yes"
  9. maximizeButton="no"
  10. minimizeButton="no"
  11. sysMenu="no"
  12. >
  13. </head>
  14. <SCRIPT LANGUAGE="VBScript">
  15.  
  16. Set WshShell = CreateObject("Wscript.Shell")
  17.  
  18. Sub modUnattend
  19.  
  20. run_button.Disabled = True
  21.  
  22. Set fso = CreateObject("Scripting.FileSystemObject")
  23.  
  24. base = Wshshell.ExpandEnvironmentStrings("%SystemRoot%")
  25. unattendFile = base & "\Panther\unattend.xml"
  26.  
  27.  
  28. computerName = ComputerNameArea.Value
  29. domainName = DomainNameArea.Value
  30. userName = UserNameArea.Value
  31. domainAdminPass = PasswordArea.Value
  32. domainAdminPassConfirm = PasswordAreaConfirm.Value
  33. OUName = OUNameArea.Value
  34.  
  35. if not domainAdminPass = domainAdminPassConfirm then
  36. msgbox("The passwords do not match.")
  37. run_button.Disabled = False
  38. exit sub
  39. end if
  40.  
  41. Set xmlDoc = CreateObject("Microsoft.XMLDOM")
  42. xmlDoc.load unattendFile
  43.  
  44. 'Iterate through Unattend.xml searching for nodes and properties to replace
  45. Set oNodes = xmlDoc.documentElement.selectNodes("/unattend/settings/component/ComputerName")
  46. For each n in oNodes
  47. n.text = computerName
  48. xmlDoc.save unattendFile
  49. Next
  50.  
  51. Set oNodes = xmlDoc.documentElement.selectNodes("/unattend/settings/component/Identification/Credentials/Domain")
  52. For each n in oNodes
  53. n.text = domainName
  54. xmlDoc.save unattendFile
  55. Next
  56.  
  57. Set oNodes = xmlDoc.documentElement.selectNodes("/unattend/settings/component/Identification/Credentials/Password")
  58. For each n in oNodes
  59. n.text = domainAdminPass
  60. xmlDoc.save unattendFile
  61. Next
  62.  
  63. Set oNodes = xmlDoc.documentElement.selectNodes("/unattend/settings/component/Identification/Credentials/Username")
  64. For each n in oNodes
  65. n.text = userName
  66. xmlDoc.save unattendFile
  67. Next
  68.  
  69. Set oNodes = xmlDoc.documentElement.selectNodes("/unattend/settings/component/Identification/JoinDomain")
  70. For each n in oNodes
  71. n.text = domainName
  72. xmlDoc.save unattendFile
  73. Next
  74.  
  75. Set oNodes = xmlDoc.documentElement.selectNodes("/unattend/settings/component/Identification/MachineObjectOU")
  76. For each n in oNodes
  77. n.text = OUName
  78. xmlDoc.save unattendFile
  79. Next
  80.  
  81. 'launch the continuation of setup in a hidden window and wait for return
  82. 'if we dont wait, closing mshta, closes windeploy.exe
  83. WshShell.Run "%WINDIR%\System32\oobe\windeploy.exe", 0, True
  84. idTimer = window.setTimeout("closeHTA", 5000, "VBScript")
  85. End Sub
  86.  
  87. Sub closeHTA
  88. window.close
  89. End Sub
  90.  
  91. Sub commandLine
  92. WshShell.Run "%WINDIR%\System32\cmd.exe", 1, True
  93. End Sub
  94.  
  95. </SCRIPT>
  96. <body>
  97. <table border="0">
  98. <tr>
  99. <td>Computer Name:</td>
  100. <td><input type="text" name="ComputerNameArea" size="30" maxlength="15" value="computer"></td>
  101. </tr>
  102. <tr>
  103. <td>Domain Name:</td>
  104. <td><input type="text" name="DomainNameArea" size="30" value="domain.local"></td>
  105. </tr>
  106. <tr>
  107. <td>Container OU:</td>
  108. <td>
  109. <select size="1" name="OUNameArea">
  110. <option value="OU=someou,DC=domain,DC=local">Desktops</option>
  111. <option value="OU=someotherou,DC=domain,DC=local">Laptops</option>
  112. </select>
  113. </td>
  114. </tr>
  115. <tr>
  116. <td>User Name:</td>
  117. <td><input type="text" name="UserNameArea" size="30"></td>
  118. </tr>
  119. <tr>
  120. <td>Password:</td>
  121. <td><input type="password" name="PasswordArea" size="30"></td>
  122. </tr>
  123. <tr>
  124. <td>Confirm Password:</td>
  125. <td><input type="password" name="PasswordAreaConfirm" size="30"></td>
  126. </tr>
  127. </table>
  128. <p align="right">
  129. <input id=runbutton class="button" type="button" value="Continue" name="run_button" onClick="modUnattend">
  130. <p align="center">
  131. Note: The following characters are invalid for use in the computer name: " `~!@#$%^&<span onClick="commandLine">*</span>()=+[]{}\|;:'",<>/?. "
  132. You will not recieve any warning regarding incorrectly supplied parameters during setup. If any of them are incorrect, setup completion
  133. may take a long time.
  134. </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement