Windows Command Line: The ASSOC Command

Windows Command Line: The ASSOC Command

Are you ready to dive deeper into the vast world of the Windows command line? In this blog post, we'll explore the ASSOC command, a powerful tool that allows you to manage file associations effectively. Whether you're a seasoned system administrator or an aspiring command line aficionado, understanding how and when to use ASSOC can significantly enhance your productivity. So, let's get started!

Note: In the video, I personally shorten the command "verbally" to "Assoch," it is worth mentioning that among other technicians I interact with, the most common pronunciation for the ASSOC command is "uh-sok" (with a short "o" sound).

Getting Started:

To access the command line window, navigate to the Start menu, type "CMD," and then launch the Command Prompt by clicking "Run as administrator" to wield the full power of your administrative privileges.

Using the ASSOC Command:

Let's begin by understanding the basic usage of the ASSOC command. By running this command without any additional parameters, you can quickly view a list of file associations on your system. Simply type "assoc" in the command line window, and voila! A comprehensive list of file associations will be displayed.

Locating the Desired File Association:

To narrow down your focus and find a specific file association, it's essential to identify the file extension you're curious about. For instance, let's say you frequently work with Microsoft Word files (with the .docx extension). By locating the relevant file extension in the list, you can identify the associated file type and subsequently determine how it opens by default. If you simply want to see what ".docx" is associated with, you can use the following code:

assoc | findstr ".docx"

This will pipe the output of the "assoc" command to the "findstr" command, using the string ".docx" as the search term. The result will display only the line of code that we are looking for.

Modifying File Associations:

Now, let's unleash the power of the ASSOC command to modify a file association. In this example, we'll change the default file association for .docx files from a text document to Microsoft Word. Follow these steps to achieve the desired result:

  1. Open the command line window and clear the previous input.

  2. Enter the command "assoc .docx=Word.Document.8" (I said "wind" in the video... don't put that. Use the file extension you wish to associate with .docx. if it is Microsoft Word use "Word.Document.8").

  3. Press Enter to execute the command.

Checking the Modified Association:

To ensure that our modification was successful, let's review the updated file association. Clear the screen in the command line window and re-enter the "assoc" command. This time, you should see the updated file association, confirming that .docx files are now associated with Microsoft Word. You can run the

assoc | findstr ".docx"

command again to speed up the process. You should now see this:

Exploring the Help Page:

Although the ASSOC command may appear straightforward, it's always helpful to explore the accompanying documentation to gain a deeper understanding. Typing:

assoc /?

in the command line window will display the command's help page. While it may seem overwhelming at first glance, this resource provides valuable insights into using the command effectively.

Common assochiations.

NOTE: the number at the end might not be the correct one for your version of the software. You can look it up here:

Microsoft Word for .docx files:

assoc .docx=Word.Document.8
  1. Adobe Acrobat Reader for .pdf files:
assoc .pdf=AcroExch.Document
  1. Google Chrome for .htm and .html files:
assoc .htm=ChromeHTML
assoc .html=ChromeHTML
  1. Mozilla Firefox for .htm and .html files:
assoc .htm=FirefoxHTML
assoc .html=FirefoxHTML
  1. Windows Media Player for .mp3 files:
assoc .mp3=WMP11.AssocFile.MP3
  1. Microsoft Excel for .xls and .xlsx files:
assoc .xls=Excel.Sheet.8
assoc .xlsx=Excel.Sheet.12

Note: Replace "OfficeXX" in the file paths with the appropriate version of Microsoft Office installed on your system.

Finding File Type Names for Program Associations

To associate a file type with a specific program, such as Adobe Acrobat or Microsoft Word, it's essential to know the exact file type name. This information allows you to set the association accurately. But how do you find the correct file type names? Let's explore the process for Adobe Acrobat and Microsoft Word:

1. Finding the File Type Name for Adobe Acrobat

To associate PDF files with Adobe Acrobat, follow these steps:

  1. Open a Command Prompt window by pressing Windows Key + R, typing "cmd" in the Run dialog, and pressing Enter.

  2. In the command prompt, type the following command and press Enter:

     ftype | findstr "Acrobat"
    

    This command searches the file type associations for the specified program name, in this case, "Acrobat."

  3. The command prompt will display the file type association that contains the program name. Look for the line that corresponds to Adobe Acrobat. For example, you might see:

     Acrobat.Document=AcroExch.Document
    

    Here, "Acrobat.Document" is the file type name associated with Adobe Acrobat.

2. Finding the File Type Name for Microsoft Word

To associate DOCX files with Microsoft Word, follow these steps:

  1. Open a Command Prompt window.

  2. Type the following command and press Enter:

     ftype | findstr "Word"
    

    This command searches the file type associations for the specified program name, in this case, "Word."

  3. The command prompt will display the file type association that contains the program name. Look for the line that corresponds to Microsoft Word. For example, you might see:

     Word.Document.12=WinWord.Document.12
    

    Here, "Word.Document.12" is the file type name associated with Microsoft Word.

By using these methods, you can easily find the correct file type names for Adobe Acrobat and Microsoft Word. With this information, you can proceed to associate the desired file types with the respective programs using the assoc command.

Remember, accurately associating file types with specific programs can enhance your productivity and streamline your workflow when working with different file formats.

Conclusion:

Congratulations on unlocking the potential of the ASSOC command! By mastering this essential tool, you've gained the ability to manage file associations efficiently, maximizing your productivity in the Windows command line environment. Remember, the command line offers an array of powerful functionalities, and it's worth exploring various approaches to accomplish your goals. Should you have any questions, feel free to delve into the vast online resources or consult fellow command line enthusiasts. Happy command line adventures!

Did you find this article valuable?

Support Matthew Hard by becoming a sponsor. Any amount is appreciated!