Launcher.bat 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. @echo off
  2. setlocal enabledelayedexpansion
  3. :: ====================================================
  4. :: PowerShell Script Launcher for Office Privacy & Telemetry Disabler
  5. :: ====================================================
  6. title Office Privacy and Telemetry Disabler Launcher
  7. :: Set script directory
  8. set "SCRIPT_DIR=%~dp0"
  9. :: Define PowerShell paths
  10. set "PS7_PATH=C:\Program Files\PowerShell\7\pwsh.exe"
  11. set "PS7_PREVIEW_PATH=C:\Program Files\PowerShell\7-preview\pwsh.exe"
  12. set "PS5_PATH=C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
  13. :: Initialize variables
  14. set "PS_EXE="
  15. set "PS_SCRIPT="
  16. set "PS_VERSION="
  17. :: Check for PowerShell 7 first (preferred)
  18. if exist "%PS7_PATH%" (
  19. set "PS_EXE=%PS7_PATH%"
  20. set "PS_SCRIPT=%SCRIPT_DIR%script\office_privacy_telemetry_disabler.ps1"
  21. set "PS_VERSION=PowerShell 7"
  22. goto :found_powershell
  23. )
  24. :: Check for PowerShell 7 Preview
  25. if exist "%PS7_PREVIEW_PATH%" (
  26. set "PS_EXE=%PS7_PREVIEW_PATH%"
  27. set "PS_SCRIPT=%SCRIPT_DIR%script\office_privacy_telemetry_disabler.ps1"
  28. set "PS_VERSION=PowerShell 7 Preview"
  29. goto :found_powershell
  30. )
  31. :: Check for PowerShell 5
  32. if exist "%PS5_PATH%" (
  33. set "PS_EXE=%PS5_PATH%"
  34. set "PS_SCRIPT=%SCRIPT_DIR%script\office_privacy_telemetry_disabler.ps1"
  35. set "PS_VERSION=PowerShell 5"
  36. goto :found_powershell
  37. )
  38. :: No PowerShell found
  39. echo [ERROR] No compatible PowerShell version found!
  40. echo.
  41. echo Please install either:
  42. echo - PowerShell 7 (recommended)
  43. echo - PowerShell 5 (Windows PowerShell)
  44. echo.
  45. pause
  46. exit /b 1
  47. :found_powershell
  48. :: Check if the PowerShell script exists
  49. if not exist "%PS_SCRIPT%" (
  50. echo [ERROR] PowerShell script not found: %PS_SCRIPT%
  51. echo.
  52. echo Make sure office_privacy_telemetry_disabler.ps1 is in the 'script' subdirectory.
  53. echo.
  54. pause
  55. exit /b 1
  56. )
  57. echo.
  58. echo ====================================================
  59. echo Office Privacy and Telemetry Disabler Launcher
  60. echo.
  61. echo by EXLOUD
  62. echo https://github.com/EXLOUD
  63. echo.
  64. echo ====================================================
  65. echo.
  66. echo Using: %PS_VERSION%
  67. echo Script location: %PS_SCRIPT%
  68. echo.
  69. echo This will disable telemetry and privacy features for:
  70. echo - Microsoft Office 2010-2024
  71. echo - Office logging and telemetry
  72. echo - Customer Experience Improvement Program
  73. echo - Connected Experiences
  74. echo - Automatic updates and notifications
  75. echo - Scheduled telemetry tasks
  76. echo.
  77. :confirmation
  78. set /p "CONFIRM=Do you want to continue? (Y/N): "
  79. if /i "!CONFIRM!"=="y" goto :proceed
  80. if /i "!CONFIRM!"=="yes" goto :proceed
  81. if /i "!CONFIRM!"=="n" goto :cancel
  82. if /i "!CONFIRM!"=="no" goto :cancel
  83. echo Invalid input. Please enter Y or N.
  84. goto :confirmation
  85. :cancel
  86. echo.
  87. echo Operation cancelled by user.
  88. pause
  89. exit /b 0
  90. :proceed
  91. cls
  92. echo.
  93. echo [INFO] Launching Office Privacy Disabler on %PS_VERSION% ...
  94. echo.
  95. echo [WARNING] Administrator rights may be required for some registry changes.
  96. echo.
  97. :: Change directory to script location
  98. cd /d "%SCRIPT_DIR%"
  99. :: Launch PowerShell script with execution policy bypass
  100. "%PS_EXE%" -ExecutionPolicy Bypass -NoProfile -File "%PS_SCRIPT%"
  101. :: Check exit code
  102. if %errorLevel% == 0 (
  103. echo.
  104. echo [SUCCESS] Script completed successfully!
  105. echo.
  106. echo Office privacy and telemetry settings have been disabled.
  107. echo Some changes may require restarting Office applications.
  108. ) else (
  109. echo.
  110. echo [ERROR] Script encountered errors. Exit code: %errorLevel%
  111. echo.
  112. echo This may happen if:
  113. echo - Office is not installed
  114. echo - Administrator rights are required
  115. echo - Registry access is restricted
  116. )
  117. echo.
  118. echo Press any key to exit...
  119. pause >nul
  120. exit /b 0