次の方法で共有


USMT Capture Status Notification HTA in Full Operating System

 

 

Recently, I had a customer that wanted separate, stand-alone USMT Capture and USMT Restore task sequences.  They had key depot locations that would allow users to drop off an old machine, and have the depot technicians image and restore data to a new device.  They would then repurpose the old machine.

Evidently, they had issues with USMT not running successfully or perhaps it was forgotten by the technician in the first place.  So they asked for a notification box to pop up and let the technician know the data was, in fact, captured successfully.

The requirement was to make a notification box pop up and pause the task sequence until it is acknowledged or closed. 

I created a simple HTA that will look for the scanstate.log in the CCM\Logs\SMSTSlog folder based on architecture.  As I am sure you are aware, the SMSTSLog folder is where the logs are placed during the task sequence, so they are always guaranteed to be current.  It isn’t until the task sequence is closed out that the logs are moved one level up and the SMSTSLog folder removed.

If they are running on a Windows XP machine the path is:

C:\Windows\System32\CCM\Logs\SMSTSLog\scanstate.log.

If they are running on a Windows 7 x64 machine, the path is:

C:\Windows\SysWow64\CCM\Logs\SMSTSLog\scanstate.log

 

The HTA then parses this log file looking for ‘MIGACTIVITY_SUCCESS’.  If this message exists in the log file, the HTA returns the following box…

image

 

If it doesn’t exist, they see the following box…

image

 

Now that the HTA is functional, I have to put it in the task sequence and make it visible while running inside the full operating system.  This is where the fun really begins…

Luckily, we can take advantage of ServiceUi.exe that exists in the Tools\x86 or Tools\x64 folders within the Microsoft Deployment Toolkit package.  We can launch this by calling it from %toolroot%.

Placing my HTA file in a folder called CustomScripts underneath the Scripts folder in the toolkit package allows me to use the command line…

%toolroot%\serviceui.exe –process:tsprogressui.exe %systemroot%\system32\mshta.exe %scriptroot%\CustomScripts\USMTCaptureStatus.hta

Here is an example of how to call my HTA using the ServiceUi.exe…

CaptureNotificationTaskCommand

 

 

 

For more information on the use of ServiceUI.exe, see ‘Can I use ServiceUI.exe to launch other programs besides the UDI Setup Wizard?’ on Cameron’s Blog – Cravings of System Center.

 

USMTCaptureStatus.hta

<html>
< head>
< title>USMT Capture Status</title>
< HTA:APPLICATION
APPLICATIONNAME="USMT Capture Status"
ID="USMTCaptureStatus"
SCROLL="no"/>
< /head>

<script language="VBScript">

' *****************
' * Window_OnLoad *
' *****************

Sub Window_OnLoad
'This method will be called when the application loads
window.resizeTo 600,300
window.moveto 1,1
USMTStatus
End Sub

' *****************
' * USMTStatus *
' *****************

Sub USMTStatus
Const ForReading = 1

' Set the search parameter
Set objRegEx = CreateObject("VBScript.RegExp")
objRegEx.Pattern = "MIGACTIVITY_SUCCESS"

' Prepare log file connectivity
Set objFSO = CreateObject("Scripting.FileSystemObject")

' WMI Connectivity
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

' Query WMI for processor architecture type
Set colProcessors= objWMIService.ExecQuery ("Select * From Win32_Processor")

' Set log file location based on processor architecture type
For Each objProcessor in colProcessors
If objProcessor.Architecture = 0 Then
Set objFile = objFSO.OpenTextFile("C:\windows\system32\ccm\logs\SMSTSLog\scanstate.log", ForReading)
Else
Set objFile = objFSO.OpenTextFile("C:\windows\syswow64\ccm\logs\SMSTSLog\scanstate.log", ForReading)
End If

' Set initial returnSuccess to 'False'
returnSuccess = False

' Parse the scanstate.log file for search parameters
Do Until objFile.AtEndOfStream
strSearchString = objFile.ReadLine
Set colMatches = objRegEx.Execute(strSearchString)
If colMatches.Count > 0 Then
For Each strMatch in colMatches
returnSuccess = True
Next
End If
Loop

' Set HTA pop-up box text based on search results
If returnSuccess = True Then
DataArea.InnerHTML = "The user state was SUCCESSFULLY captured.<br><br>PLEASE CLOSE THIS BOX TO END THE TASK SEQUENCE."
Else
DataArea.InnerHTML = "The user state was NOT SUCCESSFULLY captured.<br><br>PLEASE CLOSE THIS BOX TO END THE TASK SEQUENCE."
End If

 

Next

End Sub   

 

< /script>

<body bgcolor= "white">

<span id = "DataArea"> </span>

<!--{{InsertControlsHere}}-Do not remove this line-->

</body>
< /html>

USMTCaptureStatus.zip

 

 

This post was contributed by Brad Tucker, a Senior Consultant with Microsoft Services, East Region, United States

Disclaimer: The information on this site is provided "AS IS" with no warranties, confers no rights, and is not supported by the authors or Microsoft Corporation. Use of included script samples are subject to the terms specified in the Terms of Use

Comments

  • Anonymous
    January 01, 2003
    Great idea.  Thanks for the input.

  • Anonymous
    January 01, 2003
    Brad....Thanks for the post. Using the code you provided I was able to add a button that called trace32.exe to open the USMTCapturerestore log during and MDT deployment. This way, if needed, our field techs can launch right into the logs making it easier for final determination of successfailure much easier. Thanks.