A user exit script is effectively a function library that can be called during the processing of the CustomSettings.ini file using the UserExit directive. A user exit script contains one or more functions that can be called during the process of the CustomSettings.ini file.

A user exit script is called by specifying the UserExit directive and assigning the property name of the script to be called—for example, UserExit=TrimAssetTag.vbs. A function within the user exit script is called by specifying the name of a function enclosed in the # characters. For example, if the user exit script contains a function called TrimAssetTag(), it would be called by specifying #TrimAssetTag()#.

Parameters can be passed to the function in the user exit script in the usual way by specifying the parameter while calling the function. For example, to pass the variable %ASSETTAG% to the function TrimAssetTag(), the function would be called by specifying #TrimAssetTag(“%ASSETTAG%”)#.

The value returned by the function can be assigned to a variable by assigning the function to that variable. For example, to take the asset tag of a computer and trim it using the function TrimAssetTag(), and to then reassign the trimmed asset tag to the variable AssetTag, the CustomSettings.ini file would read AssetTag=#TrimAssetTag(“%ASSETTAG%”)#.

An example of how this could be used is to determine the task sequence to be run based on a rule that sets the TaskSequenceID property.

Listing 3 is an example user exit script that determines the task sequence to be run based on the amount of available RAM. This script also uses the ZTIUtility logging class.

Listing 3. Example User Exit Script

Function UserExit(sType, sWhen, sDetail, bSkip)

  UserExit = Success

End Function

 

Function SetTaskSequence(vMemory)

 

  oLogging.CreateEntry "UserExit - Determining Task " & _

    "Sequence to run based on available RAM", LogTypeInfo

 

  If vMemory <= 2048 Then

    SetTaskSequence ="XP_X86"

    oLogging.CreateEntry "UserExit - Available RAM: " & _

      vMemory & ". Selecting XP_X86 TS.", LogTypeInfo

  Else

    SetTaskSequence ="Vista_X86"

    oLogging.CreateEntry "UserExit - Available RAM: " & _

      vMemory & ". Selecting Vista_X86 TS.", LogTypeInfo

  End If

End Function

The user exit script should be placed in the Scripts folder on the deployment share (for example, D:\Production Deployment Share\Scripts).

To create the user exit script

4.   Create and test the custom script to be used.

5.   Locate the MDT Scripts folder (for example, D:\Production Deployment Share\Scripts).

6.   Copy the custom script to the Scripts folder.

With the user exit script added to the deployment share (in this case, Z-RAMTest.wsf), it must then be referenced in the CustomSettings.ini file for the deployment share so it is called during deployment.

To call the user exit script from CustomSettings.ini

7.   Click Start, and then point to All Programs. Point to Microsoft Deployment Toolkit, and then click Deployment Workbench.

8.   In the Deployment Workbench console tree, go to Deployment Workbench/Deployment Shares/deployment_share (where deployment_share is the name of the deployment share to configure).

9.   In the Actions pane, click Properties.

10. Click the Rules tab to display the CustomSettings.ini file.

11. Add sections to UserExit.vbs to call the required functionality using the principles described in the previous section. An example CustomSetting.ini file is shown in Listing 4.

12. Click OK to submit the changes.

13. In the details pane, click deployment_share (where deployment_share is the name of the deployment share to configure).

14. In the Actions pane, click Update Deployment Share.

The Update Deployment Share Wizard starts.

15. On the Options page, select Optimize the boot image updating process, and then click Next.

16. On the Summary page, verify the details are correct, and then click Next.

17. On the Confirmation page, click Finish.

Another common use for the user exit script is to dynamically set the computer name from known MDT properties such as SerialNumber, Model, or Product.

Listing 4. Example CustomSettings.ini for Calling the User Exit Script

[Settings]

Priority=Default

 

[Default]

OSInstall=Y

TaskSequenceID=#SetTaskSequence("%MEMORY%")#

UserExit=Z-RAMTest.vbs

 

UserDataLocation=NONE

SkipCapture=YES

SkipAdminPassword=NO

SkipProductKey=YES


Related Topics

Customizing MDT Configuration Files