How to prevent SQL files opening new instances of SSMS 17.9.1? Synopsis

This is not a new problem and there are several solutions floating around on Internet.

Problem

When you double click on a .sql file, a new instance of SSMS is opened. I did not have this problem until new SQL Server Management Studio (SSMS 17.9.1) was installed.

What I tried


This page lists several solutions suggesting registry changes and file associations, and reinstalling SSMS. None worked.
This one has almost the same as the previous link. (SO is so much better than those forums.)
Registry changes are shown here with excellent screenshots. I added "%1" but that did not make any difference.
The suggestion mentioned on SO did not work either.
On DBA, it is mostly talking about raised permissions, which is not the case with my situation.


Workarounds

Yes, I know about these workarounds:


Ctrl + O
Drag .sql files to SSMS


I am not looking for workarounds.

My environment

Even with the new SSMS 17.9.1 (build: 14.0.17289.0), I am still pointing to SQL Server 2016 (13.0.5233.0). Previously, I was using SSMS June 2016 (build: 13.0.15000.23) with the same SQL Server (13.0.5233.0).

Because of permission, I am not running any application as administrator.



SQL Server versions are listed here.

SQL Server Management Studio versions are listed here.
I have encountered this issue after installing SSMS 18 instead of 17.9. Then I have tried solutions from the list above but none worked. Uninstalling SSMS 18 and installing 17.9 again did not work either. I was finally able to resolve this issue with SSMS 18, but I hope it will fix incorrect behavior of SSMS 17 as well. First of all I've uninstalled SSMS, then I've searched through registry to find and remove all meaningful nodes containing info about SSMS or sql_auto_file. I removed the following nodes (don't forget to backup each of them prior to deleting!):


HKEY_CLASSES_ROOT.sql
HKEY_CLASSES_ROOT\Applications\Ssms.exe
HKEY_CLASSES_ROOT\sql_auto_file
HKEY_CURRENT_USER\Software\Microsoft\SQL Server Management Studio
Removed all records for ssms in HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts 
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts.sql
HKEY_USERS.DEFAULT\Software\Microsoft\SQL Server Management Studio


Then I've restarted my PC, then installed SSMS 18, then restarted again. After that SSMS opens sql files in existing SSMS instance and explorer has correct file icon assigned (document with small database icon)