Set CMTrace as Default Log File Viewer

Use this script in a TS to set the Default Log File Viewer for *.LOG and *.LO_ files in Windows.

I originally got this script from Jorgen at CCMexec.com who has some great content, but I just shortened it a bit for my own use to use in my Windows Server 2016/2019 Build TS running as a “Run PowerShell Script” step.

##################################################################
# 
# Script Name:     Set_CMTrace.ps1
#
# Description:       Sets CMTrace Tool as Default Log Viewer
#
# Version History: 1.0 - Initial Script
#
##################################################################

# Create .Log and .Lo_ Keys to make CMTrace.exe the Default Log Viewer
New-Item -Path HKLM:\SOFTWARE\Classes\.lo_ -Value "Log.File" -Force -ErrorAction SilentlyContinue
New-Item -Path HKLM:\SOFTWARE\Classes\.log -Value "Log.File" -Force -ErrorAction SilentlyContinue
New-Item -Path HKLM:\SOFTWARE\Classes\Log.File\shell\open\command -Value "`"C:\Windows\CCM\CMTrace.exe`" `"%1`"" -Force -ErrorAction SilentlyContinue

#Create ActiveSetup to remove CMTrace question if it should be the Default Log Reader
New-Item -Path "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\CMtrace" -Force -ErrorAction SilentlyContinue
New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\CMtrace" -Name "Version" -Value 1 -PropertyType String -Force -ErrorAction SilentlyContinue
New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\CMtrace" -Name "StubPath" -Value "reg.exe ADD HKCU\Software\Microsoft\Trace32 /v ""Register File Types"" /d 0 /f" -PropertyType ExpandString -Force -ErrorAction SilentlyContinue

5 thoughts on “Set CMTrace as Default Log File Viewer”

  1. I think there is something wrong with line 10

    Looks wrong in the ISE and errors with
    New-Item : A positional parameter cannot be found that accepts argument ‘C:\Windows\CCM\CMTrace.exe %1‘.

    Reply
    • The formatting seemed to get messed up when I pasted it for the post and added some extra characters in that I didn’t notice. I’ve updated it, thanks for letting me know!

      Reply
  2. Be careful when using this script in tandem with the Group Policy object “set a default associations configuration file” – I found that the OP’s script was working only in one of my OUs, that I was already setting a line as follows: “”

    It wasn’t working in my other OUs that used a different xml file as its default associations, but it immediately started working when I added that line from the first xml, to the non-working one.

    Reply
  3. ah i see the wordpress filtering is stripping out my example – with the brackets removed, what is supposed to be between those two quotations was

    Association Identifier=”.log” ProgId=”Log.File” ApplicationName=”Configuration Manager Trace Log Tool”

    Reply
  4. should be
    New-Item -Path HKLM:\SOFTWARE\Classes\.lo_ -Value “Log.File” -Force -ErrorAction SilentlyContinue
    New-Item -Path HKLM:\SOFTWARE\Classes\.log -Value “Log.File” -Force -ErrorAction SilentlyContinue

    Reply

Leave a Comment