Jump to content

HELP:MODIFY UNATTENDED WINDOWS_XML in the auto it script


Recommended Posts

Hi i  have a customized windows 7 imaging script with an unattended XML installation.I want to change the OU and probably add a domain to the XML.file.how do i do it in the script?.i am little something like currently the  unattended win7 _XML file looks like this

<JoinDomain>test.Ct.Com</JoinDomain>

 

                <MachineObjectOU>OU=Computers,OU=site,DC=Global,DC=Test,DC=Com</MachineObjectOU>    in the XML file?.my script copies the xml and other windows files from the server and executes it.below is the script.any help will be my much appreciated.

 

 

FileCopy("R:\Windows7\Config\Sysprep\TestW7_64.xml", @SystemDir & "\TestW7temp.XMl")
    $xml = FileRead(@SystemDir & "\TestW7temp.XMl")
    $xml = StringReplace($xml, "Compname", $compname)
    $xml = StringReplace($xml, "userid", $cmdline[1])
    $xml = StringReplace($xml, "userpass", $cmdline[2])
    $xml = StringReplace($xml, "Site", $site)
    $xml = StringReplace($xml, "localtimezone", $ltz)
    $xml = StringReplace($xml, "EN-US", $lang)
    FileOpen(@SystemDir & "\TestW7.XMl", 1)
    FileWrite(@SystemDir & "\TestW7.XMl", $xml)
    FileClose(@SystemDir & "\TestW7.XMl")
    GUISetState(@SW_SHOW, $w7image)
    GUICtrlSetData($i1, "Image Transfer" & @TAB & "Preparing Drive")
    If $model = "iMac11,2" Then
        RunWait("diskpart.exe /s r:\utility\diskpart_MAC.txt", "", @SW_HIDE)
        $scmd = "R:\utility\rtconsole.exe R:\Utility\imagex.exe /apply r:\windows7\image\core_w7e_64_boot.wim 1 P:\ /scroll"
    Else
        RunWait("diskpart.exe /s r:\utility\diskpart.txt", "", @SW_HIDE)
        $scmd = "R:\utility\rtconsole.exe R:\Utility\imagex.exe /apply r:\windows7\image\core_w7e_64_boot.wim 1 B:\ /scroll"
    EndIf
    GUICtrlSetData($i1, "Image Transfer" & @TAB & "Preparing Drive Complete...")
    $foo = Run($scmd, "", "", 2 + 4)
    $line1 = "0"
    ProgressOn("", "", $line1, "", 500)
    GUICtrlSetData($i1, "Image Transfer" & @TAB & "Preparing Image")
    While 1
        Sleep(50)
        If NOT ProcessExists("rtconsole.exe") Then ExitLoop
        $line = StdoutRead($foo)
        If StringInStr($line, "ImageX Tool for Windows") <> 0 Then $line = 0
        If StringInStr($line, "Progress: 100%") <> 0 Then ExitLoop
        If StringInStr($line, "Error") <> 0 Then ExitLoop
        $line = StringStripWS($line, 7)
        $line3 = StringSplit($line, @CRLF)
        $line1 = StringSplit($line, "%")
        $line = StringRight($line1[1], 2)
        If @error Then
            MsgBox(0, "Drive Access Failure", "Unable to write to drive." & @CRLF & "If SEE is present, format using an XP CD" & @CRLF & @error)
            GUIDelete()
            GUIDelete()
            GUIDelete()
            adminmenu()
        EndIf
        If StringInStr($line3[1], "Progress:") > 0 Then
            ProgressSet($line, $line3[1], "Installing System Partition")
            GUICtrlSetData($i1, "Image Transfer" & @TAB & "Progress: " & $line & "%")
        EndIf
    WEnd
    ProgressOff()
    While 1
        Sleep(1000)
        If NOT ProcessExists("rtconsole.exe") Then ExitLoop
    WEnd
    $scmd = "r:\utility\rtconsole r:\utility\imagex.exe /apply r:\windows7\image\core_w7e_64_data.wim 1 P:\ /scroll"
    $foo = Run($scmd, "", "", 2 + 4)
    $line1 = "0"
    ProgressOn("", "", $line1, "", 500)
    GUICtrlSetData($i1, "Image Transfer" & @TAB & "Preparing Windows Image")
    While 1
        Sleep(50)
        If NOT ProcessExists("rtconsole.exe") Then ExitLoop
        $line = StdoutRead($foo)
        If StringInStr($line, "ImageX Tool for Windows") <> 0 Then $line = 0
        If StringInStr($line, "Progress: 100%") <> 0 Then ExitLoop
        If StringInStr($line, "Error") <> 0 Then ExitLoop
        $line = StringStripWS($line, 7)
        $line3 = StringSplit($line, @CRLF)
        $line1 = StringSplit($line, "%")
        $line = StringRight($line1[1], 2)
        If @error Then
            GUIDelete()

Edited by nabs
ok
Link to comment
Share on other sites

#include <Array.au3>
$xml = "<root>" & @CRLF & _
"   <JoinDomain>{domain}</JoinDomain>" & @CRLF & _
"   <MachineObjectOU>OU=Computers,OU={site},DC=Global,DC=Coach,DC=Com</MachineObjectOU>" & @CRLF & _
"</root>"


Local $oXML = ObjCreate("Microsoft.XMLDOM")
$oXML.LoadXML($xml)
$oDomain = $oXML.selectSingleNode("//JoinDomain")
$oMachine = $oXML.selectSingleNode("//MachineObjectOU")

$oDomain.text = "SomeNewDomain.internal"
$sMachineOU = $oMachine.text
$aMachineOU = StringSplit($sMachineOU,",",2)
For $i = 0 To UBound($aMachineOU)-1
    If StringLeft($aMachineOU[$i],2)="OU" And Not ($aMachineOU[$i]="OU=Computers") Then
        $aMachineOU[$i] = "OU=SomeNewDomain.internal"
    EndIf
Next
$oMachine.text=_ArrayToString($aMachineOU,",")

ConsoleWrite($oXml.xml & @CRLF)
; $oXML.Save("c:\something\something.xml")

If you want to read the XML from a file rather than a string, use $oXML.load("c:\something\something.xml")

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...