Pamiiruq

update-cygwin.bat

Feb 19th, 2015
393
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. :::::::::::::::::::::::::::::::::::::::::
  2. :: Automatically check & get admin rights
  3. :::::::::::::::::::::::::::::::::::::::::
  4. @echo off
  5. CLS
  6. ECHO.
  7. ECHO =============================
  8. ECHO Running Admin shell
  9. ECHO =============================
  10.  
  11. :checkPrivileges
  12. NET FILE 1>NUL 2>NUL
  13. if '%errorlevel%' == '0' ( goto gotPrivileges ) else ( goto getPrivileges )
  14.  
  15. :getPrivileges
  16. if '%1'=='ELEV' (shift & goto gotPrivileges)
  17. ECHO.
  18. ECHO **************************************
  19. ECHO Invoking UAC for Privilege Escalation
  20. ECHO **************************************
  21.  
  22. setlocal DisableDelayedExpansion
  23. set "batchPath=%~0"
  24. setlocal EnableDelayedExpansion
  25. ECHO Set UAC = CreateObject^("Shell.Application"^) > "%temp%\OEgetPrivileges.vbs"
  26. ECHO UAC.ShellExecute "!batchPath!", "ELEV", "", "runas", 1 >> "%temp%\OEgetPrivileges.vbs"
  27. "%temp%\OEgetPrivileges.vbs"
  28. exit /B
  29.  
  30. :gotPrivileges
  31. ::::::::::::::::::::::::::::
  32. ::START
  33. ::::::::::::::::::::::::::::
  34. setlocal & pushd .
  35.  
  36. powershell -Command "& {(new-object System.Net.WebClient).DownloadFile('http://cygwin.com/setup-x86_64.exe','setup-x86_64.exe')}"
  37.  
  38. if errorlevel 1 (
  39.    echo Failed to download Cygwin installer.
  40.    exit.
  41. ) else (
  42.    setup-x86_64.exe --upgrade-also --quiet-mode
  43. )
  44.  
  45. if errorlevel 1 echo Something went wrong with the Cygwin installer.
  46. del setup-x86_64.exe
  47. pause
Advertisement
Add Comment
Please, Sign In to add comment