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


 <#  
 .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  
   

Related Posts:

  • Customizing the ZTIBiosCheck.wsf file for MDT/SCCM As there is not much documentation on how to use the ZTIBiosCheck.wsf file with MDT/SCCM, I had to figure a lot of it out. The WSF file retrieves the BIOS data via WMI queries to compare against the data stored in the ZTIBIO… Read More
  • VBScript Software Installation With as often as I deploy software, I created a standard VBScript template to use when needing to create an unattended application installation. One thing that I do not have in this script is and uninstall procedure, which I… Read More
  • List all systems that are logged off I wrote this script in 2010 to be able to give me a list of systems that are currently logged off from a list of computers in a text file. My purpose for this was to be able to find systems to test software deployments on in… Read More
  • Java Runtime Environment Installation Script This VB script I wrote will uninstall all previous versions of Java Runtime Environment. It will also install both the x86 and x64 versions, depending on whether the OS is 64-bit compatible. It uses the msi installer, which … Read More
  • USMT 4.0 PC-to-PC Migration Script This script will execute the USMT, migrating data from the old machine to the new machine. Both PCs must be on the network. You will be prompted to enter the old computer name, new computer name, and the username. This is t… Read More

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