sysprep 中にコンピューターに名前を付けて、それをドメインに自動的に追加できるようにする hta があります (コードの多くは Web 上の誰かから借りました)。ただし、次のように変更したいと思います。コードはこちら: http://pastebin.com/NQm1sn0f
「ネットワーク」というフィールドがあります。ネットワーク「A」が選択された場合、この変数を定義済みの値に設定したいと思います:
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>