Changing Visual Studio 2017 private registry settings

Visual Studio traditionally includes several settings that can be set only in registry (HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\[version] key). For example, Find result format, UseSolutionNavigatorGraphProvider or EnableVSIPLogging.

Visual Studio 2015 registry settings

Visual Studio 2015 registry settings

Visual Studio 2017 continues to support these settings, but now uses the RegLoadAppKey function to store registry keys in a private binary file under %LOCALAPPDATA%\Microsoft\VisualStudio\15.0_ [id]\privateregistry.bin:

To edit this file in Registry Editor, first make sure Visual Studio is closed (plus it takes about 20 seconds for all Visual Studio background process to shutdown), then select HKEY_LOCAL_MACHINE or HKEY_USERS and then File – Load Hive…:

When the file is loaded, you can change registry settings as usual:

Don’t forget to unload the hive when finished, or you will get an unknown error loading Visual Studio:

You can automate hive loading and unloading with the following VS2017PrivateRegistry.cmd batch file (close target Visual Studio 2017 instances with the background processes and then run the file with administrator rights):

for /d %%f in (%LOCALAPPDATA%\Microsoft\VisualStudio\15.0_*) do reg load HKLM\_TMPVS_%%~nxf "%%f\privateregistry.bin"
regedit
for /d %%f in (%LOCALAPPDATA%\Microsoft\VisualStudio\15.0_*) do reg unload HKLM\_TMPVS_%%~nxf

It loads registry keys for all Visual Studio 2017 instances as HKLM\_TMPVS_[id], starts Registry Editor and unloads keys when you close Registry Editor:

If you do have multiple instances of VS 2017 installed (e.g. Community and Enterprise, or a general release and a preview) and want to find corresponding instance ids, you can use the Visual Studio Locator utility. Included with the installer as of Visual Studio 2017 version 15.2 and later at %ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe:

If you want to quickly set a registry setting to a specific value, there is a simpler approach. A running Visual Studio 2017 instance not only loads registry keys with the RegLoadAppKey function from the privateregistry.bin file, but also redirects all registry operations under the HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\15.0 key to the private registry. Code running in the Visual Studio 2017 process can use standard registry API to set these settings:

var key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\VisualStudio\15.0");
key.SetValue("UseSolutionNavigatorGraphProvider", 0);

Just execute the following commands once from Visual Studio (e.g. with the Visual Commander extension) to set corresponding settings: Change find result format to remove the full path, Hide class info in Solution Explorer, Show the GUID and ID of menu or command when Ctrl+Shift is pressed.

As you see, customizing Visual Studio 2017 with internal settings is still possible with a bit more work.

This entry was posted in Visual Studio tips and tagged . Bookmark the permalink.

1 Response to Changing Visual Studio 2017 private registry settings

  1. Open-minded Patriot says:

    You can also use vsregedit.exe

Leave a comment