Launcher.bat 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. @echo off
  2. setlocal enabledelayedexpansion
  3. :: ====================================================
  4. :: Check for admin rights
  5. :: ====================================================
  6. >nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
  7. if '%errorlevel%' NEQ '0' (
  8. echo Requesting elevation...
  9. goto UACPrompt
  10. )
  11. goto Admin
  12. :UACPrompt
  13. echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
  14. echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"
  15. "%temp%\getadmin.vbs"
  16. del "%temp%\getadmin.vbs"
  17. exit /B
  18. :Admin
  19. pushd "%CD%"
  20. CD /D "%~dp0"
  21. :: ====================================================
  22. :: Office Privacy and Telemetry Disabler Launcher
  23. :: ====================================================
  24. title Office Privacy and Telemetry Disabler Launcher
  25. :: Set script directory
  26. set "SCRIPT_DIR=%~dp0"
  27. :: Define PowerShell paths
  28. set "PS7_PATH=C:\Program Files\PowerShell\7\pwsh.exe"
  29. set "PS7_PREVIEW_PATH=C:\Program Files\PowerShell\7-preview\pwsh.exe"
  30. set "PS5_PATH=C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
  31. :: Initialize variables
  32. set "PS_EXE="
  33. set "PS_SCRIPT="
  34. set "PS_VERSION="
  35. set "SCRIPT_TYPE="
  36. :: ====================================================
  37. :: Find PowerShell Executable
  38. :: ====================================================
  39. if exist "%PS7_PATH%" (
  40. set "PS_EXE=%PS7_PATH%"
  41. set "PS_VERSION=PowerShell 7"
  42. goto :found_powershell
  43. )
  44. if exist "%PS7_PREVIEW_PATH%" (
  45. set "PS_EXE=%PS7_PREVIEW_PATH%"
  46. set "PS_VERSION=PowerShell 7 Preview"
  47. goto :found_powershell
  48. )
  49. if exist "%PS5_PATH%" (
  50. set "PS_EXE=%PS5_PATH%"
  51. set "PS_VERSION=PowerShell 5"
  52. goto :found_powershell
  53. )
  54. echo [ERROR] No compatible PowerShell version found!
  55. echo.
  56. echo Please install either:
  57. echo - PowerShell 7 (recommended)
  58. echo - PowerShell 5 (Windows PowerShell)
  59. echo.
  60. pause
  61. exit /b 1
  62. :found_powershell
  63. :: ====================================================
  64. :: Detect Windows Version
  65. :: ====================================================
  66. for /f "tokens=4-5 delims=. " %%i in ('ver') do (
  67. set "WIN_MAJOR=%%i"
  68. set "WIN_MINOR=%%j"
  69. )
  70. if !WIN_MAJOR! GEQ 10 (
  71. set "SCRIPT_BASENAME=office_privacy_telemetry_disabler.ps1"
  72. set "SCRIPT_TYPE=Windows 10/11"
  73. ) else (
  74. set "SCRIPT_BASENAME=office_privacy_telemetry_disabler_win7+.ps1"
  75. set "SCRIPT_TYPE=Windows 7/8/8.1"
  76. )
  77. :: ====================================================
  78. :: Locate Script
  79. :: ====================================================
  80. set "SCRIPT_FOUND="
  81. set "TEST_SCRIPT=%SCRIPT_DIR%!SCRIPT_BASENAME!"
  82. if exist "!TEST_SCRIPT!" (
  83. set "PS_SCRIPT=!TEST_SCRIPT!"
  84. set "SCRIPT_FOUND=YES"
  85. goto :script_found
  86. )
  87. set "TEST_SCRIPT=%SCRIPT_DIR%script\!SCRIPT_BASENAME!"
  88. if exist "!TEST_SCRIPT!" (
  89. set "PS_SCRIPT=!TEST_SCRIPT!"
  90. set "SCRIPT_FOUND=YES"
  91. set "SCRIPT_TYPE=!SCRIPT_TYPE! (from script folder)"
  92. goto :script_found
  93. )
  94. echo [ERROR] Expected script !SCRIPT_BASENAME! not found!
  95. echo.
  96. echo Please make sure this script exists:
  97. echo - !SCRIPT_BASENAME!
  98. echo Either in the same folder as this launcher or in the 'script' subfolder.
  99. echo.
  100. pause
  101. exit /b 1
  102. :script_found
  103. :: ====================================================
  104. :: Display Information
  105. :: ====================================================
  106. echo.
  107. echo ====================================================
  108. echo Office Privacy and Telemetry Disabler Launcher
  109. echo.
  110. echo by EXLOUD
  111. echo https://github.com/EXLOUD
  112. echo ====================================================
  113. echo.
  114. echo System Information:
  115. echo - PowerShell: %PS_VERSION%
  116. echo - Script: !SCRIPT_TYPE!
  117. echo - Location: !PS_SCRIPT!
  118. echo.
  119. echo This will disable telemetry and privacy features for:
  120. echo - Microsoft Office 2010-2024
  121. echo - Office logging and telemetry
  122. echo - Customer Experience Improvement Program
  123. echo - Connected Experiences
  124. echo - Automatic updates and notifications
  125. echo - Scheduled telemetry tasks
  126. echo.
  127. :confirmation
  128. set /p "CONFIRM=Do you want to continue? (Y/N): "
  129. if /i "!CONFIRM!"=="y" goto :proceed
  130. if /i "!CONFIRM!"=="yes" goto :proceed
  131. if /i "!CONFIRM!"=="n" goto :cancel
  132. if /i "!CONFIRM!"=="no" goto :cancel
  133. echo Invalid input. Please enter Y or N.
  134. goto :confirmation
  135. :cancel
  136. echo.
  137. echo Operation cancelled by user.
  138. pause
  139. exit /b 0
  140. :proceed
  141. cls
  142. echo.
  143. echo [INFO] Launching Office Privacy Disabler...
  144. echo [INFO] PowerShell: %PS_VERSION%
  145. echo [INFO] Script: !SCRIPT_TYPE!
  146. echo.
  147. echo [WARNING] Administrator rights may be required for some registry changes.
  148. echo.
  149. cd /d "%SCRIPT_DIR%"
  150. "%PS_EXE%" -ExecutionPolicy Bypass -NoProfile -File "!PS_SCRIPT!"
  151. if %errorLevel% == 0 (
  152. echo.
  153. echo [SUCCESS] Script completed successfully!
  154. echo.
  155. echo Office privacy and telemetry settings have been disabled.
  156. echo Some changes may require restarting Office applications.
  157. ) else (
  158. echo.
  159. echo [ERROR] Script encountered errors. Exit code: %errorLevel%
  160. echo.
  161. echo This may happen if:
  162. echo - Office is not installed
  163. echo - Administrator rights are required
  164. echo - Registry access is restricted
  165. )
  166. echo.
  167. echo Press any key to exit...
  168. pause >nul
  169. exit /b 0