Advertisement
vanhoivo

Untitled

Aug 15th, 2015
471
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.20 KB | None | 0 0
  1. @echo off
  2.  
  3.  
  4. title Disable/Enable Windows 10 Automatic Updates
  5. color 1f
  6. :Begin UAC check and Auto-Elevate Permissions
  7. :-------------------------------------
  8. REM  --> Check for permissions
  9. >nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
  10.  
  11.  
  12. REM --> If error flag set, we do not have admin.
  13. if '%errorlevel%' NEQ '0' (
  14. echo:
  15. echo   Requesting Administrative Privileges...
  16. echo   Press YES in UAC Prompt to Continue
  17. echo:
  18.  
  19.  
  20.     goto UACPrompt
  21. ) else ( goto gotAdmin )
  22.  
  23.  
  24. :UACPrompt
  25.     echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
  26.     echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"
  27.  
  28.  
  29.     "%temp%\getadmin.vbs"
  30.     exit /B
  31.  
  32.  
  33. :gotAdmin
  34.     if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
  35.     pushd "%CD%"
  36.     CD /D "%~dp0"
  37. :--------------------------------------
  38.  
  39.  
  40. :Check Windows Version
  41. wmic os get version | find /i "10.">nul 2>nul
  42. if %errorlevel% neq 0 GOTO :Not10
  43.  
  44.  
  45. :Check the key:
  46. (reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" /v "NoAutoUpdate"|find /i "0x1")>NUL 2>NUL
  47. if %errorlevel% neq 0 GOTO :KEYOFF
  48.  
  49.  
  50. :KEYON
  51. echo ============================================================
  52. echo Automatic Updates are currently disabled.
  53. echo Would you like to re-enable them? (Y/N)
  54. echo ============================================================
  55. echo.
  56. choice /c yn /n
  57. If %ERRORLEVEL% NEQ 1 GOTO :QUIT
  58.  
  59.  
  60. echo Attempting to shut down the Windows Update service if it's running
  61. net stop wuauserv>NUL 2>NUL
  62. echo.
  63.  
  64.  
  65. Echo Changing Registry key
  66. REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" /v "NoAutoUpdate" /D 0 /T REG_DWORD /F>NUL 2>NUL
  67. IF %ERRORLEVEL% NEQ 0 GOTO :ERROR
  68. Echo.
  69.  
  70.  
  71. Echo Automatic Updates have been enabled
  72. Echo.
  73. goto :QUIT
  74.  
  75.  
  76.  
  77.  
  78. :KEYOFF
  79. echo ============================================================
  80. echo Automatic Updates are currently enabled.
  81. echo Would you like to disable them? (Y/N)
  82. echo ============================================================
  83. echo.
  84. choice /c yn /n
  85. If %ERRORLEVEL% NEQ 1 GOTO :QUIT
  86.  
  87.  
  88. echo Attempting to shut down the Windows Update service if it's running
  89. net stop wuauserv>NUL 2>NUL
  90. echo.
  91.  
  92.  
  93. Echo Changing Registry key
  94. REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" /v "NoAutoUpdate" /D 1 /T REG_DWORD /F>NUL 2>NUL
  95. IF %ERRORLEVEL% NEQ 0 GOTO :ERROR
  96. Echo.
  97.  
  98.  
  99. Echo Automatic Updates have been disabled
  100. Echo.
  101. goto :QUIT
  102.  
  103.  
  104.  
  105.  
  106. :QUIT
  107. echo ============================================================
  108. echo Press any key to exit...
  109. echo ============================================================
  110. pause>NUL
  111. goto :EOF
  112.  
  113.  
  114. :ERROR
  115. echo ============================================================
  116. echo The script ran into an unexpected error setting reg key.
  117. echo Press any key to exit...
  118. echo ============================================================
  119. pause>NUL
  120. goto :EOF
  121.  
  122.  
  123. :Not10
  124. echo ============================================================
  125. echo This script is only designed for Windows 10...
  126. echo Press any key to exit...
  127. echo ============================================================
  128. pause>NUL
  129. goto :EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement