mandiant / VM-Packages

Chocolatey packages supporting the analysis environment projects FLARE-VM & Commando VM.
Apache License 2.0
123 stars 61 forks source link

Create Function for File Association for "Open With" #1015

Closed emtuls closed 2 months ago

emtuls commented 2 months ago

Details

After diving into something that @binjo brought up, it appears to me that currently, we do not have any way to add a default file/executable to open specific file types.

For example, while 7zip associates itself with certain file types for a right click option (https://github.com/mandiant/VM-Packages/blob/main/packages/7zip-nsis.vm/tools/chocolateyinstall.ps1#L38C107-L38C124), it does not make itself the default executable to open those file types, leading to the file types having either no associated icon for the file or other default icons.

It would be nice for file types that we want to associate 7zip with, like those listed https://github.com/mandiant/VM-Packages/blob/main/packages/7zip-nsis.vm/tools/chocolateyinstall.ps1#L36, to also have 7zip as the icon for those files as well.

This would require mimicing how 7zip does this action when you manually click "Open With" and select 7zFM.

To do this, we will need to add HKEY_CURRENT_USER\SOFTWARE\Classes\7z_auto_file\shell\open\command to have (Default): "C:\Program Files\7-Zip\7zFM.exe" "%1"

This provides a central 7zip "Open With" that we can use for other file types to use. For each of those file types, we would just need to do something like: HKEY_CURRENT_USER\SOFTWARE\Classes\.7z and add (Default): 7z_auto_file, which is an example of just the .7z file type.

I propose we make a function that can do this for us inside of common.vm and call it something like VM-Set-Open-With-Association.