06 February 2015

Deploying CMTrace

CMTrace makes reading .log files much easier. Deploying it though can be somewhat tricky. I have written this PowerShell script that will install CMTrace and associates .log with the application. The association portion of this only works if the user has not manually associated a .log file. I have also written this to be compatible with both 32-bit and 64-bit systems.

All that needs to be done here is to make sure the CMTrace.exe is in the same directory as the PowerShell script. 

You can download the script from here.

NOTE: There is a newer and more robust version of the CMTrace installed located here

   Install CMTrace  
   Install CMTrace.exe and associate .log files  
   Mick Pletcher  
   06 February 2015  
   powershell.exe -executionpolicy bypass -file install.ps1  
 $RelativePath = (split-path $SCRIPT:MyInvocation.MyCommand.Path -parent)+"\"   
 $Architecture = Get-WmiObject -Class Win32_OperatingSystem | Select-Object OSArchitecture  
 $Architecture = $Global:Architecture.OSArchitecture  
 If ($Architecture -eq "32-bit") {  
      Copy-Item -Path $RelativePath"CMTrace.exe" -Destination $env:ProgramFiles"\Windows NT\Accessories" -Force  
      $Parameters = "Ftype logfile="+[char]34+$env:ProgramFiles+"\Windows NT\Accessories\CMTrace.exe"+[char]34+" %1"  
      cmd.exe /c $Parameters  
 } else {  
      Copy-Item -Path $RelativePath"CMTrace.exe" -Destination ${env:ProgramFiles(x86)}"\Windows NT\Accessories" -Force  
      $Parameters = "FType logfile="+[char]34+${env:ProgramFiles(x86)}+"\Windows NT\Accessories\CMTrace.exe"+[char]34+" %1"  
      cmd.exe /c $Parameters  
 $Parameters = "assoc .log=logfile"  
 cmd.exe /c $Parameters  


  1. Can you please explain the line $Parameters = "assoc .log=logfile"
    What is the logic to make it a default .log viewer?
    Thank you.

    1. CMTrace is so much better than using notepad, which is why I prefer in my environment to make it the default .log file viewer