Last active
January 26, 2024 18:13
-
-
Save noamnotyou/23c7234dfedea64f493d008b1fd045c0 to your computer and use it in GitHub Desktop.
Overrides Visual Studio's theme when in high contrast mode. This script will force Visual Studio to use the theme you select in the prompt quickly and easily instead of manually messing with RegEdit.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
prompt $G | |
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system" | |
if %errorlevel% neq 0 ( | |
set endmsg=This script can only work if ran as admin. Aborting... | |
goto end | |
) | |
echo Make sure Visual Studio is closed before you continue. | |
echo Script made by Noam Schvetz (noamnotyou). | |
:hasAdmin | |
set dark=1ded0138-47ce-435e-84ef-9ec1f439b749 | |
set light=de3dbbcd-f642-433c-8353-8f1df4370aba | |
set blue=a4d6a176-b948-4b29-8c66-53c97a1ed7d0 | |
set addcont=ce94d289-8481-498b-8ca9-9b6191a315b9 | |
echo Make sure Visual Studio is closed before you continue. | |
echo. | |
echo Select theme to replace Visual Studio's High Contrast: | |
echo D = dark | |
echo L = light | |
echo B = blue | |
echo A = blue (extra contrast) | |
echo C = cancel / exit | |
echo. | |
choice /c dlbac /n | |
if %errorlevel%==1 set selectedtheme=%dark% | |
if %errorlevel%==2 set selectedtheme=%light% | |
if %errorlevel%==3 set selectedtheme=%blue% | |
if %errorlevel%==4 set selectedtheme=%addcont% | |
if %errorlevel%==5 exit | |
echo. | |
echo. | |
echo Loading VS hive... | |
@echo off | |
reg load HKU\VisualStudioHive "%localappdata%\Microsoft\VisualStudio\16.0_bd72de21\privateregistry.bin" > nul | |
echo Done. | |
echo. | |
md "%temp%\VS_ForceDarkTheme" | |
echo Created working directory. | |
echo. | |
reg export "HKU\VisualStudioHive\Software\Microsoft\VisualStudio\16.0_bd72de21_Config\Themes\{%selectedtheme%}" "%temp%\VS_ForceDarkTheme\original-exported.reg" /y > nul | |
echo Exported selected theme to working directory. | |
echo. | |
echo Setting new values... | |
timeout /t 1 /nobreak > nul | |
powershell -Command "(gc '%temp%\VS_ForceDarkTheme\original-exported.reg') -replace '%selectedtheme%', 'a5c004b4-2d4b-494e-bf01-45fc492522c7' | Out-File -encoding UTF8 '%temp%\VS_ForceDarkTheme\modified.reg'" | |
:isDone | |
if %errorlevel% neq 0 ( | |
echo Still not done... Waiting 1 more second | |
timeout /t 1 /nobreak > nul | |
goto isDone | |
) | |
echo Done. | |
echo. | |
echo Applying theme and cleaning up... | |
regedit /s "%temp%\VS_ForceDarkTheme\modified.reg" | |
reg unload HKU\VisualStudioHive > nul | |
rmdir /s /q "%temp%\VS_ForceDarkTheme" | |
echo Done. | |
echo. | |
echo. | |
set endmsg=Finished. | |
:end | |
echo %endmsg% | |
pause |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment