Avatar of janhoedt
janhoedt

asked on 

CMTrace: open .log by default WITHOUT popup?

Hi,

I want to make cmtrace.exe the default viewer on a W10 system using Powershell. So when a user opens a .log it will open Cmtrace.
How can I do this WITHOUT the popup "do you want to open .log with cmtrace by default"?

J.
Powershell

Avatar of undefined
Last Comment
Coralon
Avatar of Coralon
Coralon
Flag of United States of America image

You need to modify the default file association by using the XML file.
1. You export your file associations (dism /online /export-defaultappassociations:c:\defaultappassociations.xml)
2. Modify it and add your entry for .log; your cmtrace.exe needs to have a file type already registered.  By default, .log is associated as a txtfile.  (Look in the registry under HKCR\txtfile and you'll see how it is configured.
3. Save your file, and reimport it (dism /online /import-defaultappassociations:c:\defaultappassociations.xml)
4. Then the worst part - move the XML file to a share, and use your group policy under Computer Configuration\Administrative Templates\File Explorer\Set a default associations configuration file.  I have tried to do this locally with no real luck.

This only works for new profiles.  Existing profiles will not be overridden.

The other option is to use a login script with the SetUserFTA utility from this site: https://kolbi.cz/blog/2017/10/25/setuserfta-userchoice-hash-defeated-set-file-type-associations-per-user/ 
With that utility, you can associate it, and not have to worry about it.  

It used to be much easier, but MS really made it a p.i.t.a.  with Windows 10. They added a hashing routine in the user's key, so that anything not in the default file associations gets saved with a hash value, and if you try to change it without the matching hash, it will revert it automatically.  (It was partly because 3rd party programs were over-writing FTA's without the user's consent.  This is supposed to prevent this hijacking, but it made administration a nightmare.)

Coralon
Avatar of janhoedt
janhoedt

ASKER

The link you posted gives "page not found".
Avatar of janhoedt
janhoedt

ASKER

Also you post "I have tried to do this locally with no real luck. " so why should I try it then?
ASKER CERTIFIED SOLUTION
Avatar of Coralon
Coralon
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of janhoedt
janhoedt

ASKER

? So it doesn't work? And you want me to still try?
Avatar of janhoedt
janhoedt

ASKER

Why would I use an exe if it can be done via a script? I'd prefer to do it via a script, actually that's the only option for me.
Avatar of Coralon
Coralon
Flag of United States of America image

I'm not in a position to try it myself (we have a lot of very strict change control rules).  
It should work from a share - Microsoft built it to work that way. I believe the changes for this are ridiculous..

I did see a script solution that involved basically generating a new association type.  I tracked it down, and I was looking to rewrite in straight PS, but haven't had the time yet.
https://p0w3rsh3ll.wordpress.com/2018/11/08/about-file-associations/

Coralon
Powershell
Powershell

Windows PowerShell is a task automation and configuration management framework from Microsoft, consisting of a command-line shell and associated scripting language built on the .NET Framework. PowerShell provides full access to the Component Object Model (COM) and Windows Management Instrumentation (WMI), enabling administrators to perform administrative tasks on both local and remote Windows systems as well as WS-Management and Common Information Model (CIM) enabling management of remote Linux systems and network devices.

27K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo