Where does Visual Studio 2017 store its config?

徘徊边缘 提交于 2019-11-26 17:30:08
Geir Sagberg

I found the answer in this blog post:

See how empty is the regular HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\15.0 key on my machine and notice that there is no 15.0_Config key:

Instead, the VS 2017 private registry is stored in your AppData folder:

Fortunately, you can use regedit.exe to load a private hive. You need to select the HKEY_USERS node, and click the File > Load Hive… menu. You select the privateregistry.bin file, give a name to the hive (I entered “VS2017PrivateRegistry”) and now you can see the 15.0_Config key populated as usual (note: use File > Unload Hive when done):

Using this guide, I was able to load the private registry, do the changes from the SO answer mentioned earlier, unload the hive and start VS 2017 with the Dark Theme!

EDIT: I had to slightly modify the PowerShell script I used to edit the registry, here is the updated version if anyone is interested:

EDIT2: Now modified to include the loading of the private registry automatically as well, including a garbace collection to allow unloading the hive:

NOTE: You have to find your own correct path for the user name (C:\Users\Geir) and VS version (15.0_8165452c).

New-PSDrive HKU Registry HKEY_USERS

reg load 'HKU\VS2017PrivateRegistry\' "C:\Users\Geir\AppData\Local\Microsoft\VisualStudio\15.0_8165452c\privateregistry.bin"

$HighConstrastTheme = "HKU:\VS2017PrivateRegistry\Software\Microsoft\VisualStudio\15.0_8165452c_Config\Themes\{a5c004b4-2d4b-494e-bf01-45fc492522c7}"
$DarkTheme = "HKU:\VS2017PrivateRegistry\Software\Microsoft\VisualStudio\15.0_8165452c_Config\Themes\{1ded0138-47ce-435e-84ef-9ec1f439b749}"

Remove-Item -Path $HighConstrastTheme -Recurse
Copy-Item -Path $DarkTheme -Destination $HighConstrastTheme -Recurse

[gc]::collect()

reg unload 'HKU\VS2017PrivateRegistry'

I've implemented a batch-file-based approach that does everything automatically and also backs up the high contrast theme in case you need to restore it for any reason.

You can find it at https://randomshaper.blogspot.com.es/2017/06/visual-studio-2017-high-contrast-hack.html

By checking the log from Process Monitor you can see it check the same registry key.

It's just not created. You need to create it. The part of the name (e3d5273c) might be different on your machine.

The following VS2017PrivateRegistry.cmd batch file loads registry keys for all Visual Studio 2017 instances as HKLM_TMPVS_[id], starts Registry Editor for you to make changes in Visual Studio settings and unloads keys when you close Registry Editor:

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

Note: first close running Visual Studio 2017 instances with background processes and then run this file with administrator rights.

See Changing Visual Studio 2017 private registry settings for more details.

The real fix for this would be for the Visual Studio team to allow developers to set the theme. If you are interested in getting this fixed go to this VS issue report and follow it and make a comment supporting it. It is currently under consideration.

Visual Studio forces the user to use its High Contrast theme when Windows is in High Contrast mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!