Dan
Posts: 4513
Joined: Wed Apr 24, 2013 3:51 pm

File Association and Context Menu Options

Fri Feb 09, 2024 4:47 pm

Hello Advanced Installer Community!

Before diving in Advanced Installer support for file association and context menu options, let's first clarify the meaning of each option.


File association

File association in Windows refers to the mapping of file types to the applications that are used to open them. When you double-click on a file in Windows Explorer or any other file manager, Windows checks the file's extension (e.g., .txt, .docx, .jpg) to determine which application to use to open it. This association allows Windows to automatically launch the appropriate application when you interact with a file.

For example, if you double-click on a file with the ".txt" extension, Windows will typically open it with Notepad by default because Notepad is the default application associated with .txt files.

File associations can be customized by users to specify which application should be used to open a particular file type. This can be done through the "Open with" menu in Windows Explorer, where users can choose a specific application to open a file, or by changing the default program associated with a file type in the Control Panel or Settings app.

If multiple applications on your system are capable of handling a specific file association, Windows will prompt you to choose which application to use for managing that particular file type. However, on modern versions of Windows, setting the default application for a specific file extension is a user-controlled process. Unlike in older versions, programmatically changing default app settings for file types is no longer permitted. This ensures that users have full control over their file management preferences and can make personalized choices regarding which applications handle their files by default.
How to open.png
How to open.png (33.12KiB)Viewed 20445 times




Context Menu Options

The Context Menu Options, also known as the shell context menu or simply the context menu, refers to the menu that appears when you right-click on various items such as files, directories (folders), the background of the Windows Explorer window, or drives in the file manager.

The context menu provides a convenient way to access various actions or commands related to the selected item.



These actions can vary depending on the type of item clicked and the applications installed on your system, but common options include:

  • Open: Opens the selected item using its default application.
  • Cut, Copy, Paste: Allows you to cut, copy, or paste files or directories.
  • Delete: Deletes the selected item permanently.
  • Rename: Allows you to rename the selected item.
  • Properties: Opens a dialog box displaying properties and information about the selected item.

These are just a few examples of common context menu options. The actual options available may vary depending on your system configuration, installed applications, and any customizations you have made. The context menu is a versatile tool that provides quick access to various actions and commands, helping to streamline file management and navigation in Windows.



Defining File Association in Advanced Installer

In the File Association view from Advanced Installer you can define the new file extensions and make file associations.

Your application uses files with a particular extension (in our example that is "ai-txt" & “ai-txtex”.). You may want to associate that type of files to be opened or edited with your application.


For details, check the Create new file extensions and make file associations with related information for hints and guidance.


Here’s a how the files with extension "ai-txt" & “ai-txtex” will be open by my Text Editor app:
file association.png
file association.png (16.69KiB)Viewed 20429 times

After creating the file association and installing the setup package, for any file that has the "ai-txt" or “ai-txtex” extension, the files will be associated with our application and its icon will be placed on the files with the related extension:
files explorer.png
files explorer.png (24.87KiB)Viewed 20445 times

If double clicking on any of them, our application will handle those files.



Defining Context Menu Options for Files, Directory, Background & Drives in Advanced Installer

Use the [ New Shell Context Menu ] toolbar button and then select which type of context menu you want to create : Files Context Menu, Directory Context Menu, Background Context Menu, Drive Context Menu or a subentry for the currently selected shell context menu.
Context menu toolbar option.png
Context menu toolbar option.png (15.63KiB)Viewed 20445 times

Advanced Installers allows you to create a context menu for modern Windows 11 context menu. For this, just enable the Windows 11 Context Menu option:
File association view.png
File association view.png (38.22KiB)Viewed 20429 times

Since Advanced Installer is using a sparse package to create the context menu option, the digital signature is mandatory.

For testing, if using a self-signed certificate, the certificate needs to be trusted on the target machine.


The context menu options allow only 1 level of hierarchy, of creating multiple subentries, only the first level is recognized by the OS:
sub-context menu options.png
sub-context menu options.png (43.12KiB)Viewed 20445 times


After defining the context menu for files, directories and background, we can test our package.


Now, there are 2 classes that we need to take into consideration:

  • Target machine has the modern context menu e.g. Windows 11 style
  • Target machine has the classic context menu e.g. Windows 10 style
side by side context menu.png
side by side context menu.png (373.64KiB)Viewed 20445 times


Advanced Installer will handle both scenarios and make the context menu options available no matter the UI style used by the user.

Although the sparse package is installed on both machines, the context menu options will be handled through the sparse package only for modern context menu e.g. Windows 11 style, leaving the classic context menu e.g. Windows 10 style to be handled through classic registries support.



If installing the MSI package, the context menu will be correctly displayed:

Context Menu options for files:
Context menu for files.png
Context menu for files.png (127.21KiB)Viewed 20445 times


Context Menu options for folders:
Folder context menu side by side.png
Folder context menu side by side.png (149.11KiB)Viewed 20429 times



What is happening when adding the MSIX build ?

Advanced Installer will sync by default the MSI with the MSIX.

When installing the MSIX package, the file association will be accordingly handled, files with "ai-txt" & “ai-txtex” extensions will be associated with our application:

Further customization can be done in the dedicated Declarations view specific to MSIX packages:
Declarations view.png
Declarations view.png (49.65KiB)Viewed 20445 times


The context menu options from a MSIX package will only be displayed on Modern context menu e.g. Windows 11 style.

The sample project is attached to this thread, so if you are interested to take a look directly at my project, you are more than welcome to download the ZIP file. Here's the download link.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Sample Projects”