vanhoivo

Enable Or Disable Auto Update Windows 10

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