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 "<code>"C:\Windows\CCM\CMTrace.exe</code>" <code>"%1</code>"" -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

Leave a Comment