Advertisement
Guest User

sdfsdf

a guest
Jul 31st, 2015
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.82 KB | None | 0 0
  1. @echo off
  2.  
  3.  
  4. title Disable/Enable Windows Telemetry
  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 the key:
  41. (reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\DataCollection" /v "AllowTelemetry"|find /i "0x0")>NUL 2>NUL
  42. if %errorlevel% NEQ 0 GOTO :KEYOFF
  43.  
  44.  
  45. :KEYON
  46. echo ============================================================
  47. echo Windows Telemetry currently disabled.
  48. echo Would you like to re-enable it? (Y/N)
  49. echo ============================================================
  50. echo.
  51. choice /c yn /n
  52. If %ERRORLEVEL% NEQ 1 GOTO :QUIT
  53.  
  54.  
  55. Echo Deleting Telemetry Registry key
  56. REG DELETE "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\DataCollection" /v "AllowTelemetry" /F>NUL 2>NUL
  57. IF %ERRORLEVEL% NEQ 0 GOTO :ERROR
  58. Echo.
  59.  
  60.  
  61. Echo Windows Telemetry enabled
  62. Echo.
  63. goto :QUIT
  64.  
  65.  
  66.  
  67.  
  68. :KEYOFF
  69. echo ============================================================
  70. echo Windows Telemetry is currently enabled.
  71. echo Would you like to disable it? (Y/N)
  72. echo ============================================================
  73. echo.
  74. choice /c yn /n
  75. If %ERRORLEVEL% NEQ 1 GOTO :QUIT
  76.  
  77.  
  78. Echo Changing Registry key
  79. reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\DataCollection" /v "AllowTelemetry">NUL 2>NUL
  80. if %errorlevel% equ 1 REG DELETE "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\DataCollection" /v "AllowTelemetry" /F>NUL 2>NUL
  81. REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\DataCollection" /v "AllowTelemetry" /D 0 /T REG_DWORD /F>NUL 2>NUL
  82. IF %ERRORLEVEL% NEQ 0 GOTO :ERROR
  83. Echo.
  84.  
  85.  
  86. Echo Windows Telemetry disabled
  87. Echo.
  88. goto :QUIT
  89.  
  90.  
  91.  
  92.  
  93. :QUIT
  94. echo ============================================================
  95. echo Press any key to exit...
  96. echo ============================================================
  97. pause>NUL
  98. goto :EOF
  99.  
  100.  
  101. :ERROR
  102. echo ============================================================
  103. echo The script ran into an unexpected error setting reg key.
  104. echo Press any key to exit...
  105. echo ============================================================
  106. pause>NUL
  107. goto :EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement