Deployment Artist
   Minimize

 

The deployvista.com site is finally put to rest...

You find new content on the Deployment Research site, a site filled with articles and video-tutorials on how to deploy operating systems. If you are missing something on the new site, please let me know. You can find me on twitter on my @jarwidmark alias.

You can also search the old deployvista.com article archive below.

Regards / Johan Arwidmark


 Print   
 Blog_List Minimize

 Print   
 Blog_Archive Minimize

 Print   
 New_Blog Minimize
You must be logged in and have permission to create or edit a blog.

 Print   
 BDD Extension: ZTEUSMTConfigFile Minimize
Location: BlogsJason Scheffelmaer    
Posted by: Jason Scheffelmaer 2/20/2007 2:29 AM

Update 05/01/2007: Updated code to include full path to config.xml to fix the pathing issue in ZTI deployment.

ZTEUSMTConfigFile.wsf takes advantage of the Customsettings.ini rules in order to define your USMT Config file within your rules. Also the other big advantage of this extension is it copies the config file you define from the distribution share to the local hard drive so scanstate can find it during the process, something that currently does not happen in BDD today. The last item it does is it adds the argument "/config:" to the scanstate arguments for processing.

This extension was created to mimic the process of the USMTMigFiles property. It uses a customsettings.ini property, it copies the config file to the local tools folder, and it adds the command line argument for /config to the end of the scanstage arguments.

To add the ZTEUSMTConfigFile.wsf script to your scripts folder as an accessible script

1.

Copy & Paste the code below the --Code Snippet-- below in this article into a blank text file and save it as ZTEUSMTConfigFile.wsf.

2.

Copy or Move the ZTEUSMTConfigFile.wsf script to your scripts folder under your distribution share.

(Ex: \\server1\distribution$\scripts\ZTEUSMTConfigFile.wsf)

To add the required Custom Properties to your customsettings.ini or "Rules" tab of your deployment point

1.

Start Deployment Workbench.

2.

In the console tree, navigate to Deploy->Deployment Points.

3.

In the details pane, right-click dp (where dp is the deployment point whose customsettings.ini you want to modify), and then click Properties.

4.

Click the Rules tab, navigate to Properties=  and add the following custom property:

USMTConfigFile

 

5.

Set the values of the custom property in a section that will be processed by your Priorities list at the top of your customsettings.ini

Sample CustomSettings.ini snip...

Priorities=USMTSettings, Default
Properties=USMTConfigFile


[USMTSettings]
USMTMigFiles1=CustomApps.xml
USMTMigFiles2=CustomData.xml 
USMTConfigFile=Config.xml

[Default]
OSInstall=Y
...
...

Note: If this custom property is not assigned a value than the ZTEUSMTConfigFile.wsf will not process.

Note 2: Do NOT add /config: manually to your ScanStateArgs property manually as this extension will do that for you, similar to USMTMigFiles does for Migration xmls.

To add the ZTEUSMTConfigFile.wsf script as a task to the task sequence of a build

1.

Start Deployment Workbench.

2.

In the console tree, navigate to Builds.

3.

In the details pane, right-click build (where build is the build whose task sequence you want to modify), and then click Properties.

4.

Click the Task Sequence tab, navigate to Non-Upgrade group, click Add, and then click Task.

Note   Ensure that you add the task prior to the Capture User State task so that the config file is copied before scanstate runs.

5.

Complete the Properties tab of the new task by using the information in the table below, accepting default values if not otherwise specified, and then click Apply.

Completing the Properties Tab of the New Task

In this box Do this

Name

Type Process USMT Config File.

Description

Type description (where description is text that explains why the file is needed).

Command line

Type Cscript.exe “%SCRIPTROOT%\ZTEUSMTConfigFile.wsf”.

 

6.

Complete the Options tab of the new task by using the information in the table below, accepting default values if not otherwise specified, and then click OK.

Completing the Options Tab of the New Task

In this box Do this

Success codes

Type 0. (The ZTEUSMTConfigFile.wsf script returns these codes upon successful completion.)

Conditions list box

Add any conditions that might be necessary (I recommend duplicating the conditions found for Capture User State task).

 

Upon completion of adding the task to run the ZTEUSMTConfigFile.wsf script, the Capture User State task can now process the /config file without having to find or copy it manually before hand.

--Code Snippet--

<job id="ZTEUSMTConfigFile">
   <script language="VBScript" src="ZTIUtility.vbs"/>
   <script language="VBScript">

' //***************************************************************************
' // ***** Script Header *****
' //
' // Solution:  Solution Accelerator Extension for Business Desktop Deployment
' // File:      ZTEUSMTConfigFile.wsf
' //
' // Purpose:   Find and copy the USMT configuration file to the local drive for use with scanstate
' //
' // Usage:     cscript ZTEUSMTConfigFile.wsf [/debug:true]
' //  Requires The following custom properties to be defined in the customsettings.ini
' //    *  USMTConfigFile
' //
' // Customer Script Version:     1.0.3
' //
' // Extension History:
' // 1.0.4    JOS  5/01/2007  Fixed Config.xml error on ZTI in code snippet below. Check bolded code in snippet for change Uses full path now.
' // 1.0.1    JOS  2/20/2007  Added hardcoded sUSMTPath value as USMT is not installed yet. This only works with the CAB solution.
' // 1.0.0    JOS  2/19/2007  Created initial version.
' //
' // Customer History:
' //
' // ***** End Header *****
' //***************************************************************************


'//----------------------------------------------------------------------------
'//
'//  Global constant and variable declarations
'//
'//----------------------------------------------------------------------------

Option Explicit

Dim iRetVal, sUSMTPath

'//----------------------------------------------------------------------------
'//  End declarations
'//----------------------------------------------------------------------------


'//----------------------------------------------------------------------------
'//  Main routine
'//----------------------------------------------------------------------------

On Error Resume Next
iRetVal = ZTIProcess
ProcessResults iRetVal
On Error Goto 0


'//---------------------------------------------------------------------------
'//
'//  Function: ZTIProcess()
'//
'//  Input: None
'//
'//  Return: Success - 0
'//  Failure - non-zero
'//
'//  Purpose: Perform main ZTI processing
'//  
'//---------------------------------------------------------------------------
Function ZTIProcess()

 Dim oMigXML
 Dim sBaseArgs
 Dim sXML
 Dim sUSMTConfigFile
 Dim sFoundXML

 iRetVal = Success

 oLogging.CreateEntry "Retrieving USMTConfigFile property", LogTypeInfo
 
 sUSMTConfigFile = oEnvironment.Item("USMTConfigFile")

 If sUSMTConfigFile <> "" Then
  
  ' This is taken directly out of the ZTIUserState.wsf script.
  sUSMTPath = InstallUSMT

  ' Make sure the file exists in the directory
  If not oFSO.FileExists(sUSMTPath & "\" & sUSMTConfigFile) then
   iRetVal = oUtility.FindFile(sUSMTConfigFile, sFoundXML)
   If iRetVal = Success then
    oLogging.CreateEntry "Copying " & sFoundXML & " to local install directory.", LogTypeInfo
    oFSO.CopyFile sFoundXML, sUSMTPath & "\" & sUSMTConfigFile, true
   Else
    oLogging.CreateEntry "WARNING: Unable to find specified USMT migration XML file " & sUSMTConfigFile, LogTypeWarning
   End if
  Else
   iRetVal = oUtility.FindFile(sUSMTConfigFile, sFoundXML)
   If iRetVal = Success then
    If oFSO.GetFile(sFoundXML).DateLastModified > oFSO.GetFile(sUSMTPath & "\" & sUSMTConfigFile).DateLastModified then
     oLogging.CreateEntry "Copying updated " & sFoundXML & " to local install directory overwriting existing file.", LogTypeInfo
     oFSO.CopyFile sFoundXML, sUSMTPath & "\" & sUSMTConfigFile, true
    End if
   End if
  End if


  ' Add the /config command to the base arguments if file exists
  If oFSO.FileExists(sUSMTPath & "\" & sUSMTConfigFile) then
   oLogging.CreateEntry "Adding '/config:" & sUSMTConfigFile & "' to the command arguments", LogTypeInfo
   
    
   sBaseArgs = oEnvironment.Item("ScanStateArgs")
   If sBaseArgs = "" then
    sBaseArgs = "/v:5 /o /c"
   End if

   sBaseArgs = sBaseArgs & " /config:" & Chr(34) & sUSMTPath & "\" & sUSMTConfigFile & Chr(34)
   oEnvironment.Item("ScanStateArgs") = sBaseArgs

  Else
   oLogging.CreateEntry "Skipping " & sUSMTConfigFile & " because it was not found", LogTypeWarning
  End if

  
   
 Else
  oLogging.CreateEntry "USMTConfigFile property is either not defined or is empty, exiting ZTEUSMTConfigFile.wsf", LogTypeInfo

 End If

 ZTIProcess = iRetVal

End Function


'//---------------------------------------------------------------------------
'//
'//  Function: InstallUSMT
'//
'//  Input: none
'//
'//  Return: path to USMT files (blank if failure)
'//
'//  Purpose: Install the USMT 3.0 files locally
'//
'//---------------------------------------------------------------------------

Function InstallUSMT

 Dim sInstaller
 Dim iRetVal
 Dim sCmd
 Dim sUSMTPath
 Dim sExtractPath
 Dim iRetryCount


 ' Find USMT 3.0 installer and install it if it isn't already present

 If oFSO.FileExists(oEnv("ProgramFiles")  & "\USMT30\scanstate.exe") then

  ' Already installed, use it

 ElseIf oEnvironment.Item("OSVersion") = "2000" or oEnvironment.Item("OSVersion") = "XP" or oEnvironment.Item("OSVersion") = "2003" then

  ' Figure out the platform-specific installer name

  If UCase(oEnvironment.Item("Architecture")) = "X86" then
   sInstaller = "InstallUSMT30_x86_2000andXP.exe"
  Else
   sInstaller = "InstallUSMT30_x64_XP.exe"
  End if


  ' Find the UPDATE.EXE-based installer.

  iRetVal = oUtility.FindFile(sInstaller, sUSMTPath)
  If iRetVal <> Success then

   oLogging.CreateEntry "Unable to find " & sInstaller & " required to perform the user state migration.", LogTypeInfo

  Else

   ' Perform the installation

   oLogging.CreateEntry "USMT installer found at " & sUSMTPath & ".", LogTypeInfo
   sCmd = """" & sUSMTPath & """ /quiet /norestart /nobackup"
   iRetVal = oUtility.RunWithHeartbeat(sCmd)
   If iRetVal <> 0 and iRetVal <> 3010 then
    oLogging.CreateEntry "Non-zero return code from USMT 3.0 installation command, rc = " & iRetVal, LogTypeInfo
   End if

  End if

 Else  ' On Windows Vista


  ' Figure out the platform-specific installer name

  sInstaller = "InstallUSMT30_" & oEnvironment.Item("Architecture") & "_vista.msu"


  ' Find component-based installer

  iRetVal = oUtility.FindFile(sInstaller, sUSMTPath)
  If iRetVal <> Success then

   oLogging.CreateEntry "Unable to find " & sInstaller & " required to perform the user state migration.", LogTypeInfo

  Else

   ' Perform the installation

   oLogging.CreateEntry "USMT installer found at " & sUSMTPath & ".", LogTypeInfo
   sCmd = "%systemroot%\system32\wusa.exe """ & sUSMTPath & """ /quiet /norestart"

   iRetryCount = 0
   Do While iRetryCount < 5

    iRetryCount = iRetryCount + 1
    iRetVal = oUtility.RunWithHeartbeat(sCmd)
    If iRetVal = 0 or iRetVal = 3010 then
     Exit Do
    ElseIf iRetryCount < 5 then
     oLogging.CreateEntry "USMT installation failed with rc = " & iRetVal & ", will retry in 15 seconds", LogTypeInfo
     WScript.Sleep 15000
    End if

   Loop

   If iRetVal <> 0 and iRetVal <> 3010 then
    oLogging.CreateEntry "Non-zero return code from USMT 3.0 installation command, rc = " & iRetVal, LogTypeInfo
   End if

  End if

 End if


 ' See if it's there now.  If not, look for the CAB

 If oFSO.FileExists(oEnv("ProgramFiles")  & "\USMT30\scanstate.exe") then

  ' Already installed, use it

  sUSMTPath = oEnv("ProgramFiles")  & "\USMT30"

 Else

  ' Find USMT30_<architecture>.cab

  iRetVal = oUtility.FindFile("USMT30_" & oEnvironment.Item("Architecture") & ".cab", sUSMTPath)
  If iRetVal <> Success then
   oLogging.CreateEntry "ERROR: Unable to find USMT30_" & oEnvironment.Item("Architecture") & ".cab file so it is not possible to install USMT 3.0, aborting", LogTypeError
   InstallUSMT = ""
   Exit Function
  End if
  oLogging.CreateEntry "USMT 3.0 files will be extracted from " & sUSMTPath, LogTypeInfo


  ' Find EXTRACT.EXE

  iRetVal = oUtility.FindFile("EXTRACT.EXE", sExtractPath)
  If iRetVal <> Success then
   oLogging.CreateEntry "ERROR: Unable to find EXTRACT.EXE file needed to extract contents of USMT30.CAB file, aborting", LogTypeError
   InstallUSMT = ""
   Exit Function
  End if
  oLogging.CreateEntry sExtractPath & " will be used to extract contents of CAB file.", LogTypeInfo


  ' Do the extraction

  oUtility.VerifyPathExists oUtility.LocalRootPath & "\Tools\" & oEnvironment.Item("Architecture")
  sCmd = "cmd.exe /c """"" & sExtractPath & """ /y /e """ & sUSMTPath & """ /l """ & oUtility.LocalRootPath & "\Tools\" & oEnvironment.Item("Architecture") & """"""
  iRetVal = oShell.Run(sCmd, 0, true)
  If iRetVal <> 0 then
   oLogging.CreateEntry "Non-zero return code extracting cab file, rc = " & iRetVal, LogTypeError
   InstallUSMT = ""
   Exit Function
  End if


  ' Set the new path
  
  sUSMTPath = oUtility.LocalRootPath & "\Tools\" & oEnvironment.Item("Architecture")

 End if


 If oFSO.FileExists(sUSMTPath  & "\scanstate.exe") then
  oLogging.CreateEntry "USMT 3.0 is installed at " & sUSMTPath, LogTypeInfo
  InstallUSMT = sUSMTPath
 Else
  oLogging.CreateEntry "ERROR: USMT 3.0 could not be installed", LogTypeError
  InstallUSMT = ""
 End if


End Function


   </script>
</job>
  

Permalink |  Trackback

Your name:
Title:
Comment:
Add Comment   Cancel 

  
 Search_Blog Minimize

 Print   
Copyright Deployvista.com 2006-2012 (c)   Terms Of Use  Privacy Statement
DotNetNuke® is copyright 2002-2017 by DotNetNuke Corporation