06 February 2015

Deploying CMTrace

Posted By: Mick Pletcher - 3:20 PM

Share

& Comment








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


 <#  
 .SYNOPSIS  
   Install CMTrace  
 .DESCRIPTION  
   Install CMTrace.exe and associate .log files  
 .Author  
   Mick Pletcher  
 .Date  
   06 February 2015  
 .EXAMPLE  
   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  
   

About Mick Pletcher

My blog is here to help solve issues I have encountered and solved, publish scripts I have written, and educate others in understanding areas that are not well covered

2 comments:

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

    ReplyDelete
    Replies
    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

      Delete

Copyright © 2013 Mick's IT Blogs™ is a registered trademark.