Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- title Disable/Enable Windows Telemetry
- color 1f
- :Begin UAC check and Auto-Elevate Permissions
- :-------------------------------------
- REM --> Check for permissions
- >nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
- REM --> If error flag set, we do not have admin.
- if '%errorlevel%' NEQ '0' (
- echo:
- echo Requesting Administrative Privileges...
- echo Press YES in UAC Prompt to Continue
- echo:
- goto UACPrompt
- ) else ( goto gotAdmin )
- :UACPrompt
- echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
- echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"
- "%temp%\getadmin.vbs"
- exit /B
- :gotAdmin
- if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
- pushd "%CD%"
- CD /D "%~dp0"
- :--------------------------------------
- :Check the key:
- (reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\DataCollection" /v "AllowTelemetry"|find /i "0x0")>NUL 2>NUL
- if %errorlevel% NEQ 0 GOTO :KEYOFF
- :KEYON
- echo ============================================================
- echo Windows Telemetry currently disabled.
- echo Would you like to re-enable it? (Y/N)
- echo ============================================================
- echo.
- choice /c yn /n
- If %ERRORLEVEL% NEQ 1 GOTO :QUIT
- Echo Deleting Telemetry Registry key
- REG DELETE "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\DataCollection" /v "AllowTelemetry" /F>NUL 2>NUL
- IF %ERRORLEVEL% NEQ 0 GOTO :ERROR
- Echo.
- Echo Windows Telemetry enabled
- Echo.
- goto :QUIT
- :KEYOFF
- echo ============================================================
- echo Windows Telemetry is currently enabled.
- echo Would you like to disable it? (Y/N)
- echo ============================================================
- echo.
- choice /c yn /n
- If %ERRORLEVEL% NEQ 1 GOTO :QUIT
- Echo Changing Registry key
- reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\DataCollection" /v "AllowTelemetry">NUL 2>NUL
- if %errorlevel% equ 1 REG DELETE "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\DataCollection" /v "AllowTelemetry" /F>NUL 2>NUL
- REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\DataCollection" /v "AllowTelemetry" /D 0 /T REG_DWORD /F>NUL 2>NUL
- IF %ERRORLEVEL% NEQ 0 GOTO :ERROR
- Echo.
- Echo Windows Telemetry disabled
- Echo.
- goto :QUIT
- :QUIT
- echo ============================================================
- echo Press any key to exit...
- echo ============================================================
- pause>NUL
- goto :EOF
- :ERROR
- echo ============================================================
- echo The script ran into an unexpected error setting reg key.
- echo Press any key to exit...
- echo ============================================================
- pause>NUL
- goto :EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement