Todd Hemsell at myITforum.com

{Enter witty eye catching description here}

Microsoft Deployment Toolkit Wizard Editor : Part 3 : Panes can be a pain, or how to bring external data into your wizard.

Previous Posts in this Series:

  1. Microsoft Deployment Toolkit Wizard Editor : Part 1 : Introduction
  2. Microsoft Deployment Toolkit Wizard Editor : Part 2 : Global Settings and Custom Initialization and Validation scripts.

The next items we will examine are Pane Conditions. Conditions specify under what conditions the pane is displayed to the user. The idea is that any information you can provide using CustomSettings.ini or the database will be used, and any values that are missing can be obtained from the user, or simply abort the OS install. Go to the first pane and the first condition. The actual condition is “UCASE(Property("SkipTaskSequence"))<>"YES"

image

So what is going to happen with this condition? Wizard.hta is going to send it to the function EvalWithErrorHandling that is defined in WizUtility.vbs. the following graphic shows the lines from Wizard.hta that will send our condition to EvalWithErrorHandling

image

And here is the function from WizUtility.vbs It sends our condition to the vbscript Eval function.

image

If our condition evaluates to TRUE, the pane will be shown, if the condition evaluates to FALSE, then the pane will be skipped. this functionality is what will allow us to make our deployment 100% silent if we have all of the information we need, and stop and prompt for information if something we deem critical is missing.

To verify our assumption is correct lets change the condition to something we are fairly sure is true, 1 > 0  and then Save, and then Test our hypothesis by clicking the Test button. If 1 is in fact greater than 0, and if I am correct, the Pane will show.

image

OK, the pane showed up so reality is safe for now, but just to verify we are correct let’s change it to 0 > 1 (A false statement) and see if we see the SelectTaskSequence Pane

image

OK, to  sum up to this point.. You can add custom scripts using the Initialization action in global, and if a condition evaluates to true a wizard pane will be displayed, if it evaluates to false it will be skipped.

The Validate function works the same way, except it determines if the user gets to LEAVE the pane or not. this can be used to ensure you get the data you need for the deployment to come to a successful conclusion before they can continue.

The Validate function also sends the statement to the eval function as shown below

image

If the statement is returned as true the Next button will go to the next pane, if it evaluates to false nothing happens. to test this let’s use our 0 > 1 example and see if we can move to the next pane.

 image

be sure you change the condition (not validation) to 1 > 0. If you leave it as 0 > 1 where we left off you will not even see the pane. click test and then click the Next button. You should be stuck on that Pane until 0 > 1

image

OK, to  sum up to this point.. You can add custom scripts using the Initialization action in global, and if a condition evaluates to true a wizard pane will be displayed, if it evaluates to false it will be skipped. If a validation statement evaluates to TRUE the Next  button will work, and if the Validation statement is FALSE the next button does not do a thing.

Ok, so now we will examine the Initialization function. The initialization function runs BEFORE the html that defines the page loads. This is where we will go collect data to use in our HTML. The default for SelectTaskSequence is “InitializeTSList”.

image

The function InitializeTSList is defined in DeployWiz_Initialization.vbs. Recall we specify what other scripts to load using the initialization section in global settings.

Let’s change it to use a new function, let’s call it InitializeCONFIGURATIONListWithSampleFile. Place the function into your DeployWiz_Initialization_CUSTOM.vbs file that is specified on the global initialization

*NOTE* In the first part we made a new file and added it in there, we named it DeployWiz_Validation_CUSTOM.vbs, so you will need to create a new file DeployWiz_Initialization_CUSTOM.vbs and add a new initialization statement in global to load  it. Here is the contents of the file I am using. I will not explain what it is doing since it is so obvious.


Function InitializeCONFIGURATIONListWithSampleFile
        'Put the XML into our document
        'I really do not know what  is taking place here so if someone wants to explain it :-)
        Set oConfigurationList = oUtility.CreateXMLDOMObjectEx( "Configurations.xml" )
        CONFIGURATIONS.XMLDocument.LoadXML  oConfigurationList.xml
End Function

Sub ConfigItemChange
    document.all.item(window.event.srcElement.SourceIndex + 1).Disabled = not window.event.SrcElement.checked
End sub

Function ReadyInitializeCONFIGURATIONList
    ' We muck arround with the values, so we need to do some manual cleanup
    Dim oInput, oConfigurationList
    Dim bFound
    ButtonNext.Disabled = TRUE
    If Not ConfigList.readystate = "complete" then
        Exit function     
    End If
    Set oConfigurationList = document.getElementsByName("ConfigID")
    If oConfigurationList is nothing then
                oLogging.CreateEntry "oConfigurationList is nothing. Exiting Function", LogTypeInfo
        Exit function
    End if
    If oConfigurationList.Length > 0 then
        bFound = FALSE
        For each oInput in oConfigurationList
            If oInput.Value <> "" and StrComp(oInput.Value,ForceAsString(oproperties("ConfigID")),vbTextCompare) = 0 then
                document.all.item(oInput.SourceIndex - 1).click
                ButtonNext.Disabled = FALSE
                bFound = TRUE
            End if
        Next     
        If not bFound And oConfigurationList.Item(0).Value <> "" then
            ' Just select the first item
            document.getElementsByName("SelectedItem").Item(0).click  
            ButtonNext.Disabled = FALSE
        End if
    End if  
    If ForceAsString(oProperties("ConfigID")) <> "" then
        oProperties("ConfigID") = ""
    End if
End function

Function AssociateRequestWithMachine
  MsgBox("You Clicked the Button!")
End Function


Yea, I am  not really able to understand much of that either. When I do i will make a new blog post explaining it. That will be at some undetermined time in the future. The code above started out as one of the built in panes provided by MS. I just altered it until it worked for me.

Now we need to alter the html in the html panel so it loads the info from our XML Doc.

First I will show you the entire html, and then I will explain the parts I do understand.

Here is where it goes in the wizard editor

image

And here is the HTML


<h1>Please Select Correct Configuration </h1>

<div class=ScrollingDynamicListBox>   

<table id="ConfigList" datasrc="#CONFIGURATIONS" height: 300 width="100%" border=0 cellSpacing=0
                  language=vbscript onreadystatechange=ReadyInitializeCONFIGURATIONList>


      <tr valign=top class="DynamicListBoxRow"
          onmouseover="javascript:this.className = 'DynamicListBoxRow-over';"
          onmouseout="javascript:this.className = 'DynamicListBoxRow';" >
         

             <td class=DynamicListBoxElement width="0px">
                             <input type=radio
                                        name=SelectedItem
                                        language=vbscript onPropertyChange="ConfigItemChange" />
                               <input type=hidden
                                         Name=ConfigID datafld="ConfigID" />
             </td>
             <td language=vbscript onclick="ClickChildCheckBox" class=DynamicListBoxElement width="100%">
                    <div><Label datafld="ConfigDescription" class="Larger" ></Label></div>
                    <div><Label datafld="ConfigComments" dataformatas="HTML">


                        <label class=errmsg style='display: inline;' >No task sequences are available (CONFIGURATIONS.xml does not exist, is empty, or is inaccessible)
                        </label>

                      </Label>
                  </div>           
          </td>
    </table>
  </div>

<input type=hidden id=ConfigIDx  name=ConfigIDx>
<xml id="CONFIGURATIONS"></xml>

</br>
  <div class=WideEdit align=center>
            <input type=button Name="UpdateConfigButton" value="Tie this machine to the selected configuration" onclick="AssociateRequestWithMachine" />
   </div>




At this point you should be able to click Test and see our new data, once you download the configurations.rar and extract the xml file from it and place it in the directory with the rest fo your files

image

Next Post: What my face looked like when I first tried to decipher the HTML in the HTML Tab!

Comments

benphunter said:

Hi Todd, Great to see you finally blogging. It can be diffcult to create a custom wizard even with the MDT wizard editor. This is great stuff and should help everyone create decent custom wizards without pulling out too much hair :).

Thanks,

Ben Hunter

# April 8, 2009 5:55 PM