I created an answer file to be used for an Unattended Windows7 install. I would like to be able to modify a few settings on the fly (Time Zone, computer name, ect), but I'm new with VBScript/XML. I found a neat artical on this site VBScript Find a node in XML node and replace the value on how to use xpath. Some of my trouble is targeting the node (I think) as I haven't found an example using format. I've tried using the full and just , but in the full answer file there are several nodes with the same component name. Suggestions...please? :)
<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>
Messing around with VBs, I was able to come up with someone on my own. I do appreciate the post. This prompts for a user box as well. Is there any reason why something like this wouldn't work and do the job efficiently?
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")
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…