Guest User

Untitled

a guest
Mar 23rd, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. @echo off
  2.  
  3. reg.exe query "HKLMSOFTWAREMicrosoftMSBuildToolsVersions14.0" /v MSBuildToolsPath > nul 2>&1
  4. if ERRORLEVEL 1 goto MissingMSBuildRegistry
  5.  
  6. for /f "skip=2 tokens=2,*" %%A in ('reg.exe query "HKLMSOFTWAREMicrosoftMSBuildToolsVersions14.0" /v MSBuildToolsPath') do SET "MSBUILDDIR=%%B"
  7.  
  8. echo.
  9. echo MSBuildToolsPath: %MSBUILDDIR%
  10. echo.
  11.  
  12. IF NOT EXIST "%MSBUILDDIR%" goto MissingMSBuildToolsPath
  13. IF NOT EXIST "%MSBUILDDIR%msbuild.exe" goto MissingMSBuildExe
  14. IF EXIST "%MSBUILDDIR%Microsoft.Common.targets.bak" goto AlreadyPatched
  15.  
  16.  
  17. ::-------------------------------------
  18. REM --> Check for permissions
  19. >nul 2>&1 "%SYSTEMROOT%system32cacls.exe" "%SYSTEMROOT%system32configsystem"
  20.  
  21. REM --> If error flag set, we do not have admin.
  22. if '%errorlevel%' NEQ '0' (
  23. echo Requesting administrative privileges...
  24. goto UACPrompt
  25. ) else ( goto gotAdmin )
  26.  
  27. :UACPrompt
  28. echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%getadmin.vbs"
  29. echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%getadmin.vbs"
  30.  
  31. "%temp%getadmin.vbs"
  32. exit /B
  33.  
  34. :gotAdmin
  35. if exist "%temp%getadmin.vbs" ( del "%temp%getadmin.vbs" )
  36. pushd "%CD%"
  37. CD /D "%~dp0"
  38. ::--------------------------------------
  39.  
  40.  
  41. :: Replace MSBuild 14.0 Microsoft.Common.targets file with MSBuild 15.0 file.
  42. rename "%MSBUILDDIR%Microsoft.Common.targets" "Microsoft.Common.targets.bak"
  43. copy "MSBuil15.Microsoft.Common.targets" "%MSBUILDDIR%Microsoft.Common.targets"
  44.  
  45.  
  46. exit /b 0
  47.  
  48. goto:eof
  49. ::ERRORS
  50. ::---------------------
  51. :MissingMSBuildRegistry
  52. echo Cannot obtain path to MSBuild tools from registry
  53. goto:eof
  54. :MissingMSBuildToolsPath
  55. echo The MSBuild tools path from the registry '%MSBUILDDIR%' does not exist
  56. goto:eof
  57. :MissingMSBuildExe
  58. echo The MSBuild executable could not be found at '%MSBUILDDIR%'
  59. goto:eof
  60. :AlreadyPatched
  61. echo The Microsoft.Common.targets file is already patched
  62. goto:eof
Add Comment
Please, Sign In to add comment