The logging class in ZTIUtiliy.vbs provides a simple mechanism for custom code to log status information, warnings, and errors in the same manner as other scripts during a ZTI or LTI deployment. This standardization also ensures that the LTI Deployment Summary dialog box correctly reports the status of any custom code that is run.
Listing 20 illustrates an example custom code script that uses the oLogging.CreateEntry and TestAndFail functions to log different types of messages, depending on the results of the various script actions.
Listing 20. Example Script Using ZTIUtility Logging: ZTI_Example.wsf
<job id="ZTI_Example">
<script language="VBScript" src="ZTIUtility.vbs"/>
<script language="VBScript">
' //*******************************************************
' //
' // Copyright (c) Microsoft Corporation. All rights reserved
' // Microsoft Deployment Toolkit Solution Accelerator
' // File: ZTI_Example.wsf
' //
' // Purpose: Example of scripting with the
' // Microsoft Deployment Toolkit.
' //
' // Usage: cscript ZTI_Example.wsf [/debug:true]
' //
' //*******************************************************
Option Explicit
RunNewInstance
'//--------------------------------------------------------
'// Main Class
'//--------------------------------------------------------
Class ZTI_Example
'//--------------------------------------------------------
'// Main routine
'//--------------------------------------------------------
Function Main()
Dim iRetVal
Dim sScriptPath
iRetVal = SUCCESS
oLogging.CreateEntry "Begin example script…", _
LogTypeInfo
' %ServerA% is a generic variable available within
' every CustomSettings.ini file.
sScriptPath = "\\" & oEnvironment.Item("ServerA") & _
"\public\products\Applications\User\Technet\USEnglish"
' Validate a connection to server, net connect with
' credentials if necessary.
iRetVal = oUtility.ValidateConnection( sScriptPath )
TestAndFail iRetVal, 9991, "Validate Connection to [" & _
sScriptPath & "]"
'Run Setup Program
iRetVal = oUtility.RunWithHeartbeat( """" & _
sScriptPath & "\setup.exe"" /?" )
TestAndFail iRetVal, 9991, "RunWithHeartbeat [" & _
sScriptPath & "]"
'Perform any cleanup from installation process
oShell.RegWrite "HKLM\Software\Microsoft\SomeValue", _
"Done with Execution of XXX.", "REG_SZ"
Main = iRetVal
End Function
End Class
</script>
</job>
Note If you want to continue using scripts that call ZTIProcess() with ProcessResults(), you can continue to do so. However, certain enhanced error-handling features will not be enabled.
Related Topics