0

我有一个 hta,可以让我在 sysprep 期间命名一台计算机并将其自动添加到域中(我从网络上的其他人那里借来的大部分代码)。但是,我想对其进行修改,使其具有以下功能:此处的代码:http: //pastebin.com/NQm1sn0f

会有一个名为“network”的字段。when network "A" is chosen, i would like it to set this variables to a predefined value :

domainName = DomainNameArea.Value
userName = UserNameArea.Value
domainAdminPass = PasswordArea.Value
domainAdminPassConfirm = PasswordAreaConfirm.Value
OUName = OUNameArea.Value

基本上..如果他们选择网络 A,我会设置 domainName = "home.local", UserName = "joinaccount" , domainAdminPass = "password", OUName = "OU=workstations,DC=home,DC=Local"

如果他们选择网络 B,我当然会有不同的设置..

有人可以帮我吗?如果链接未获批准或失效,我将在此处发布代码:

<html>
<head>
<title>Computer Deployment</title>
<HTA:APPLICATION 
 ID="objCompDeploy" 
 APPLICATIONNAME="Computer Deployment"
 SCROLL="no"
 SINGLEINSTANCE="yes"
 maximizeButton="no"
 minimizeButton="no"
 sysMenu="no"
>
</head>
<SCRIPT LANGUAGE="VBScript">

Set WshShell = CreateObject("Wscript.Shell")

Sub modUnattend

run_button.Disabled = True

Set fso = CreateObject("Scripting.FileSystemObject")

base = Wshshell.ExpandEnvironmentStrings("%SystemRoot%")
unattendFile = base & "\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

</SCRIPT>
<body>
<table border="0">
<tr>
<td>Computer Name:</td>
<td><input type="text" name="ComputerNameArea" size="30" maxlength="15" value="computer"></td>
</tr>
<tr>
<td>Domain Name:</td>
<td><input type="text" name="DomainNameArea" size="30" value="domain.local"></td>
</tr>
<tr>
<td>Container OU:</td>
<td>
<select size="1" name="OUNameArea">
<option value="OU=someou,DC=domain,DC=local">Desktops</option>
<option value="OU=someotherou,DC=domain,DC=local">Laptops</option>
</select>
</td>
</tr>
<tr>
<td>User Name:</td>
<td><input type="text" name="UserNameArea" size="30"></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name="PasswordArea" size="30"></td>
</tr>
<tr>
<td>Confirm Password:</td>
<td><input type="password" name="PasswordAreaConfirm" size="30"></td>
</tr>
</table> 
<p align="right">
<input id=runbutton  class="button" type="button" value="Continue" name="run_button" onClick="modUnattend">
<p align="center">
Note: The following characters are invalid for use in the computer name: "  `~!@#$%^&<span     onClick="commandLine">*</span>()=+[]{}\|;:'",<>/?.  "
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.
</body>
4

1 回答 1

0

如果我正确理解了您的问题,您可以执行以下操作:

HTML:

<select name="networks" onchange="NetworksChanged()">
    <option value="home.local;joinaccount;password;OU=workstations,DC=home,DC=Local">Network A</option>
    <option value="guest.local;guestaccount;password2;OU=workstations,DC=guest,DC=Local">Network B</option>
</select>

和脚本:

Function NetworksChanged()
    Dim options
    options = Split(networks.value, ";")
    domainName = options(0)
    userName = options(1)
    domainAdminPass = options(2)
    domainAdminPassConfirm = options(2)
    OUName = options(3)
End Function
于 2013-10-24T07:15:17.210 回答