Jump to content
Sign in to follow this  

_XMLDomWrapper & W7 Cmdline Config of International Settings

Recommended Posts


Hi folks,

I'm trying to use the _XMLDomWrapper UDF to create an XML answer file that can be used to configure Win7 regional settings. I have a VBScript that does what I need, however, I wanted to perform the exact same thing using an AutoIt script - if nothing else for my own learning. I'm not having much luck with it though, mainly because I haven't a clue how to make this work properly.

Here's the VBScript that works:

' set the script directory
On Error Resume Next
sScriptDir = empty
sScriptDir = WScript.ScriptFullName
sScriptDir = Left(sScriptDir, InStrRev(sScriptDir, "\"))
'Set the GeoID.xml file path
sGeoIDXml=sScriptDir & "GeoID.xml"
'Call the routine
CreateXML "242"
Sub CreateXML(GeoID)
Set xmlDoc = CreateObject("Microsoft.XMLDOM")
Set objRoot = xmlDoc.createElement("gs:GlobalizationServices")
xmlDoc.appendChild objRoot
objRoot.setAttribute "xmlns:gs","urn:longhornGlobalizationUnattend"
objRoot.appendChild xmlDoc.createComment("User List ")
Set objRecord = xmlDoc.createElement("gs:UserList")
objRoot.appendChild objRecord
Set objName = xmlDoc.createElement("gs:User")
objRecord.appendChild objName
objName.setAttribute "UserID","Current"
objName.setAttribute "CopySettingsToDefaultUserAcct","true"
objRoot.appendChild xmlDoc.createComment("location ")
Set objRecord = xmlDoc.createElement("gs:LocationPreferences")
objRoot.appendChild objRecord
Set objName = xmlDoc.createElement("gs:GeoID")
objRecord.appendChild objName
objName.setAttribute "Value",GeoID
xmlDoc.Save sGeoIDXml
End Sub

Here's the XML file that the VBScript generates:

<gs:GlobalizationServices xmlns:gs="urn:longhornGlobalizationUnattend">
  <!--User List -->
    <gs:User UserID="Current" CopySettingsToDefaultUserAcct="true" />
  <!--location -->
    <gs:GeoID Value="242" />

Here's my (lame) attempt at coding something that works using AutoIt:

#include <_XMLDomWrapper.au3>
;~ Global $sPath = @ScriptDir & "\GEOID_test.xml"
Global $sRootNode = "gs:GlobalizationServices"
;~ _XMLCreateFile($sPath, $sRootNode, True)
;~ _XMLFileOpen($sPath)
;_XMLCreateAttrib($sRootNode, 'xmlns:gs="urn:longhornGlobalizationUnattend"')
;~ _XMLSetAttrib($sRootNode, "xmlns:gs", "urn:longhornGlobalizationUnattend")
;_XMLCreateAttrib("xmlns:gs", "urn:longhornGlobalizationUnattend")
;_XMLCreateFile($sFile, $sRootNode, True)
_XMLCreateFile($sFile, $sRootNode, True)
_XMLSetAttrib($sRootNode, "xmlns")

Please can you gurus out there shed some light on where I'm going wrong here?

Many thanks,


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this