I was doing an OSD project about 5 years ago when I came up with the idea of automatically opening the smsts.log file using Trace32 (now replaced by CMTrace). I am always up for a challenge to see if something can be done, so I set out to see if I could make it happen. By automatically opening the smsts.log, I could save a ton of time during the development and testing phase of engineering the task sequence.
Back in the ConfigMgr 2007 days, you would have to hit F8 in order to bring up the command prompt and then hopefully you remembered to put the Trace32 on the boot image for the WinPE phases. Now in CM12, CMTrace is included in the boot image, however, it is not in the path (see my other post called ConfigMgr 2012: Always including certain files in your Boot Images for a little trick to put CMTrace in the System32 directory so that it is in the path and can be launched from any directory). After you launch the log viewer for the first time, the first thing it does is ask you if you want to make it the default log viewer before it will continue. Setting a couple of registry keys ahead of time is all that it takes to prevent this from being displayed.
After that, it is a matter of launching the log viewer and calling smsts.log. There are two things to consider for this action: 1. Depending on the scenario (i.e. new computer or refresh), you need to know how to launch CMTrace and 2. Depending on the scenario and place in the task sequence, you need to know where the smsts.log is located. For #1, you can launch CMTrace directly if you are in WinPE or the newly installed OS during State Restore. If starting from a currently installed OS (i.e. refresh scenario), then you need to use a utility from the MDT Toolkit called ServiceUI.exe in order to make CMTrace visible. For #2, the smsts.log file starts in different locations based on the scenario and it also moves around during the task sequence.
With that said, let’s take a look at the steps that need to get inserted into a ConfigMgr R2-MDT client task sequence:
Each *DEBUG* Group has a condition on the Task Sequence Variable DEBUG (DEBUG equals “TRUE”). This variable can be set on a Collection or System Resource.
Set OS Target Architecture: this step is used to set the architecture of the OS that is being applied. For an example, use the value x64 if the new OS being installed is Windows 8.1 Enterprise x64. This is used later in order to copy the correct architecture version of CMTrace and ServiceUI onto the target OS.
Use Toolkit Package and Gather: This step is used to obtain CMTrace (which needs to be copied into the MDT Toolkit Package) and ServiceUI utilities, and also determine the current architecture under the refresh scenario.
Copy CMTrace: This step is also used in the refresh scenario and is used to copy the correct architecture version of CMTrace into System32 (which minimizes the number of registry setting steps).
Set Default Log Viewer HKCU: These three steps set the necessary registry keys in order to prevent CMTrace from prompting to be the default log viewer. Yes, they could be done via a script with a package or a very long command line, but I kept them split out and in Run Command Line steps for simplicity.
Open SMSTS Log-NEWCOMPUTER: This step opens the smsts.log in a new computer scenario using the following command: cmd /c “start x:\Windows\System32\CMTrace.exe x:\Windows\Temp\SMSTSLog\smsts.log”
Open SMSTS Log-REFRESH: This step opens the smsts.log in a refresh scenario using the following command: “%deployroot%\tools\%architecture%\ServiceUI.exe” -process:tsprogressui.exe -nowait %WINDIR%\System32\CMTrace.exe %_SMSTSLogPath%\smsts.log
Each time the task sequence boots into a new OS, the above registry entries need to be set. The following screen shots show each of the phases below:
Refresh scenario booting into WinPE:
Copying CMTrace and ServiceUI into the new OS and then rebooting into the target OS:
Closing CMTrace at the end of the task sequence:
In summary, here are the steps for getting this up and running in your environment. This assumes that you already have MDT integrated with ConfigMgr 2012 R2:
1. Add both the x86 and x64 version of CMTrace.exe to your MDT Toolkit Package. They can be found in ConfigMgr install directory\OSD\bin\i386 and ConfigMgr install directory\OSD\bin\x64. In the MDT Toolkit Package place the x86 version in .\Tools\x86 and the x64 version in .\Tools\x64. Be sure to update your Distribution Points after adding the files.
2. Download the Client Task Sequence – DEBUG.xml and copy it into the SCCM directory where the Microsoft Deployment Toolkit is installed (i.e. C:\Program Files\Microsoft Deployment Toolkit\SCCM).
3. Use the Create MDT Task Sequence action and select Client Task Sequence – DEBUG in the Choose Template drop down. Complete the wizard and edit the newly created task sequence. Select the step Set OS Target Architecture and edit the value to reflect the architecture of the WIM that is being deployed.
4. Create a Deployment and target a Collection.
5. On the targeted Collection, create a variable called DEBUG and set the value to TRUE. Add some test machines, start a deployment and watch the smsts.log open automatically!
Originally posted on http://miketerrill.net/