本帖最后由 hanz_200 于 2014-6-6 22:33 编辑
使用UDF为:_XMLDomWrapper.au3
引用版本为:好吧!我发现了这个
2010版,作者是修改了!但是没完善,是为完成品,无法正常使用的!
_XMLFileOpen
_XMLLoad ...
heavenm 发表于 2013-6-8 02:57
http://www.autoitx.com/forum.php ... C_XMLDomWrapper.au3#include <_XMLDomWrapper.au3>
$sXMLFile = "Autounattend.xml"
$result = _XMLFileOpen($sXMLFile, 'xmlns:un="urn:schemas-microsoft-com:unattend"')
If $result = 0 Then Exit
$path = '//un:unattend/un:settings[@pass="windowsPE"]/un:component[@name="Microsoft-Windows-Setup"]/un:UserData/un:ProductKey/un:Key'
$path1 = '//un:unattend/un:settings[@pass="windowsPE"]/un:component[@name="Microsoft-Windows-Setup"]/un:UserData/un:ProductKey'
$Key=_GetFirstValue($path)
MsgBox(0,"Key",$Key)
_XMLUpdateField($path1,"Key","xxxxx-xxxxx-xxxxx-xxxxx-xxxx")
; 无法更新值
Func _GetFirstValue($node)
$ret_val = _XMLGetValue($result,$node)
If IsArray($ret_val) Then
Return ($ret_val[1])
Else
Return SetError(1,3,0)
EndIf
EndFunc
Autounattend.xml 文件为:<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<settings pass="windowsPE">
<component name="Microsoft-Windows-Setup" processorArchitecture="AMD64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<UserData>
<ProductKey>
<Key>TNH8J-KG84C-TRMG4-FFD7J-VH4WX</Key>
<WillShowUI>OnError</WillShowUI>
</ProductKey>
<AcceptEula>false</AcceptEula>
<FullName>Lenovo</FullName>
<Organization>Lenovo</Organization>
</UserData>
<UseConfigurationSet>true</UseConfigurationSet>
</component>
<component name="Microsoft-Windows-International-Core-WinPE" processorArchitecture="AMD64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SetupUILanguage>
<WillShowUI>Always</WillShowUI>
</SetupUILanguage>
</component>
</settings>
<settings pass="specialize">
<component name="Microsoft-Windows-Store-Client-UI" processorArchitecture="AMD64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<StoreContentModifier>Lenovo3_Idea</StoreContentModifier>
</component>
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="AMD64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ProductKey>TNH8J-KG84C-TRMG4-FFD7J-VH4WX</ProductKey>
<OEMName>Lenovo</OEMName>
<OEMInformation>
<Manufacturer>Lenovo</Manufacturer>
<SupportURL>http://support.lenovo.com</SupportURL>
<HelpCustomized>true</HelpCustomized>
<Model>Lenovo Product</Model>
<Logo>c:\windows\System32\OOBE\info\Lenovo_logo.bmp</Logo>
</OEMInformation>
<Themes>
<DesktopBackground>%WINDIR%\Web\Wallpaper\Lenovo\LenovoWallPaper.jpg</DesktopBackground>
<ThemeName>Lenovo</ThemeName>
</Themes>
</component>
<component name="Microsoft-Windows-IE-InternetExplorer" processorArchitecture="AMD64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Home_Page>http://www.lenovo.com</Home_Page>
<Help_Page>http://support.lenovo.com</Help_Page>
<UserAgent>LENW8</UserAgent>
</component>
<component name="Microsoft-Windows-HelpAndSupport" processorArchitecture="AMD64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<HelpAndSupport>
<Logo>c:\windows\System32\OOBE\info\Lenovo_Help_logo.png</Logo>
<LogoURL>http://support.lenovo.com</LogoURL>
<Manufacturer>Lenovo</Manufacturer>
<TileColor>0</TileColor>
<SearchContent>true</SearchContent>
</HelpAndSupport>
</component>
</settings>
<settings pass="oobeSystem">
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="AMD64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<OEMName>Lenovo</OEMName>
<FirstLogonCommands>
<SynchronousCommand wcm:action="add">
<CommandLine>C:\WINDOWS\CLENOVO.CMD</CommandLine>
<Description>Remove Firstboot</Description>
<Order>89</Order>
</SynchronousCommand>
</FirstLogonCommands>
</component>
<component name="Microsoft-Windows-PerfCenterCPL" processorArchitecture="AMD64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<WindowsExperienceIndexOemInfo>
<HardwareUpgradeURL>http://www.lenovo.com</HardwareUpgradeURL>
<Logo>c:\windows\System32\OOBE\info\Lenovo_Performance_logo.bmp</Logo>
</WindowsExperienceIndexOemInfo>
</component>
</settings>
<cpi:offlineImage cpi:source="catalog:c:/users/kenpacq/desktop/images and clg files/Predeveloperpreview.clg" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
</unattend>
寻求帮助!可以获得Key,但是无法写入! |