Microsoft Word is a popular word processing software that many people use on their computers. However, there are also alternative programs available, such as LibreOffice Writer, which is a free and open-source word processor. If you prefer to use LibreOffice Writer instead of Microsoft Word, you can associate the .docx file extension with the swriter.exe executable file to make it the default program for opening .docx files. In this article, we will guide you through the process of associating .docx files with swriter.exe using PowerShell.
Step 1: Open PowerShell
The first step is to open PowerShell, which is a powerful command-line shell and scripting language. You can open PowerShell by typing "PowerShell" in the Windows search bar and selecting the "Windows PowerShell" app.
Step 2: Check Current File Association
Before we proceed with associating .docx files with swriter.exe, let's check the current file association to ensure that .docx files are not already associated with Microsoft Word. To do this, type the following command in PowerShell:
Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.docx\UserChoice"
If the output of the command shows that the "ProgId" is "Word.Document.12" or any value related to Microsoft Word, it means that .docx files are currently associated with Microsoft Word.
Step 3: Associate .docx files with swriter.exe
Now, let's proceed with associating .docx files with swriter.exe. To do this, type the following command in PowerShell:
New-Item -Path "HKCU:\Software\Classes\.docx"
Set-ItemProperty -Path "HKCU:\Software\Classes\.docx" -Name "(Default)" -Value "LibreOffice.Document.1"
New-Item -Path "HKCU:\Software\Classes\LibreOffice.Document.1"
Set-ItemProperty -Path "HKCU:\Software\Classes\LibreOffice.Document.1" -Name "(Default)" -Value "LibreOffice Writer Document"
New-Item -Path "HKCU:\Software\Classes\LibreOffice.Document.1\shell"
New-Item -Path "HKCU:\Software\Classes\LibreOffice.Document.1\shell\open"
New-Item -Path "HKCU:\Software\Classes\LibreOffice.Document.1\shell\open\command"
Set-ItemProperty -Path "HKCU:\Software\Classes\LibreOffice.Document.1\shell\open\command" -Name "(Default)" -Value """C:\Program Files\LibreOffice\program\swriter.exe"" ""%1"""
These commands create the necessary registry keys and values to associate .docx files with swriter.exe, which is the executable file for LibreOffice Writer. Make sure to replace "C:\Program Files\LibreOffice\program\swriter.exe" with the actual path to the swriter.exe file on your computer if it is located elsewhere.
Step 4: Verify the File Association
To verify that the file association has been successfully changed, you can once again check the current file association using the command from Step 2. This time, the output should show that the "ProgId" is "LibreOffice.Document.1" or a value related to LibreOffice Writer.
Now, when you double-click on a .docx file, it should open in LibreOffice Writer instead of Microsoft Word. If you have both programs installed, you can always right-click on a .docx file, select "Open with," and choose either Microsoft Word or LibreOffice Writer to open the file.
By following the steps outlined in this article, you can easily associate .docx files with swriter.exe using PowerShell. This allows you to use LibreOffice Writer as the default program for opening .docx files, providing you with an alternative to Microsoft Word.
References
| Source | Link |
|---|---|
| Microsoft Docs | https://docs.microsoft.com/en-us/powershell/scripting/overview?view=powershell-7.1 |
| LibreOffice | https://www.libreoffice.org/ |