0
我有一個hta,讓我在sysprep期間命名計算機,並自動將其添加到域(我從網上其他人借來的大部分代碼)。然而,我想修改它,使其具有以下代碼: code here:http://pastebin.com/NQm1sn0fHTA(VBScript)代碼+加入域選項
將會有一個名爲「網絡」的字段。選擇網絡「A」時,我想它這個變量設置爲預定義值:
domainName = DomainNameArea.Value
userName = UserNameArea.Value
domainAdminPass = PasswordArea.Value
domainAdminPassConfirm = PasswordAreaConfirm.Value
OUName = OUNameArea.Value
基本上..如果他們選擇的網絡A,I將設置則domainName =「home.local」,用戶名= 「joinaccount」,domainAdminPass = 「密碼」,OUName = 「OU =工作站,DC =家庭,DC =本地」
,如果他們選擇了網絡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: " `[email protected]#$%^&<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>