我创建了一个用于无人值守 Windows7 安装的应答文件。我希望能够即时修改一些设置(时区、计算机名称等),但我是 VBScript/XML 的新手。我在这个站点上找到了一篇整洁的文章VBScript Find a node in XML node and replace the value on how to use xpath。我的一些麻烦是针对节点(我认为),因为我还没有找到使用格式的示例。我试过使用 full 和 just ,但在完整的答案文件中有几个具有相同组件名称的节点。建议...请?:)
<unattend xmlns="urn.schemas-microsoft.com:unattend">
<settings pass="specialize">
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="*REMOVED*" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ProductKey>*REMOVED*</ProductKey>
<RegisteredOwner>*REMOVED*</RegisteredOwner>
<DisableAutoDaylightTimeSet>false</DisableAutoDaylightTimeSet>
<ComputerName>*</ComputerName>
<DoNotCleanTaskBar>true</DoNotCleanTaskBar>
<BluetoothTaskbarIconEnabled>false</BluetoothTaskbarIconEnabled>
<CopyProfile>true</CopyProfile>
<ShowWindowsLive>false</ShowWindowsLive>
<TimeZone>VarTime</TimeZone>
</component>
</settings>
</unattend>
与 VB 混在一起,我能够自己想出一个人。我很欣赏这篇文章。这也会提示输入用户框。有什么理由为什么这样的事情不能有效地完成工作吗?
Set xml = CreateObject("Msxml2.DOMDocument.3.0")
xml.Async = "False"
xml.load "path.xml"
strTime = InputBox("Please Select your Time Zone.")
strTimeZone = "Nothing"
if strTime= "1" then strTimeZone= "Eastern Standard Time"
if strTime= "2" then strTimeZone= "Central Standard Time"
if strTime= "3" then strTimeZone= "Mountian Standard Time"
if strTime= "4" then strTimeZone= "Pacific Stardard Time"
Set TimeZone = xml.selectSingleNode("//unattend/settings/component/TimeZone")
TimeZone.Text = strTimeZone
'Save the xml document with the new settings.
strResult = xml.save("path.xml")