Skip to content

Instantly share code, notes, and snippets.

@NickJosevski
Created June 20, 2017 04:41
Show Gist options
  • Save NickJosevski/b44eb6117b14092a127d6af156234e8e to your computer and use it in GitHub Desktop.
Save NickJosevski/b44eb6117b14092a127d6af156234e8e to your computer and use it in GitHub Desktop.
Trying to set U2DCheckVerbosity
@echo off
setlocal EnableDelayedExpansion
set U2DCheckVerbosity=1
set BatchFile=%0
if not exist "%VS150COMNTOOLS%" (
echo This script needs to be run from an elevated Visual Studio 2017 developer command prompt.
exit /b 1
)
:ParseArguments
if "%1" == "" goto :DoneParsing
if /I "%1" == "/?" call :Usage && exit /b 1
if /I "%1" == "enable" set U2DCheckVerbosity=1&&shift&& goto :ParseArguments
if /I "%1" == "disable" set U2DCheckVerbosity=0&&shift&& goto :ParseArguments
call :Usage && exit /b 1
:DoneParsing
if "%U2DCheckVerbosity%" == "1" (echo Enabling U2DCheckVerbosity...)
if "%U2DCheckVerbosity%" == "0" (echo Disabling U2DCheckVerbosity...)
set InstalledVSInstances=%ProgramData%\Microsoft\VisualStudio\Packages\_Instances
for /F %%d in ('dir /B /D "%InstalledVSInstances%"') do (
set VSInstance=%VisualStudioVersion%_%%d
set VSRegistryHive=%LOCALAPPDATA%\Microsoft\VisualStudio\!VSInstance!\privateregistry.bin
echo !VSInstance!
REM Import this VS instance's private registry into HKLM so that we can manipulate it
reg load HKLM\VS !VSRegistryHive! > nul || goto :Fail
REM Set the registry key
reg add HKLM\VS\Software\Microsoft\VisualStudio\!VSInstance!\General /v "U2DCheckVerbosity" /t REG_DWORD /d %U2DCheckVerbosity% /f > nul || goto :Fail
REM Make sure we unload it, otherwise, VS will never start again
reg unload HKLM\VS > nul || goto :Fail
)
echo.
echo Done.
exit /b 0
:Fail
echo Unable to open Visual Studio registry. Make sure you have all VS instances closed, and you are running from an elevated command prompt.
exit /b 1
:Usage
echo Usage:
echo %BatchFile% [enable^|disable]
echo.
echo enable Turns on the U2DCheckVerbosity
echo disable Turns off U2DCheckVerbosity
goto :eof
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment