-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathLauncher.bat
More file actions
218 lines (184 loc) · 5.65 KB
/
Launcher.bat
File metadata and controls
218 lines (184 loc) · 5.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
@echo off
setlocal enabledelayedexpansion
:: ====================================================
:: Define PowerShell paths
:: ====================================================
set "PS5_PATH=%systemdrive%\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
set "PS7_PATH=%ProgramFiles%\PowerShell\7\pwsh.exe"
set "PS7_PREVIEW_PATH=%ProgramFiles%\PowerShell\7-preview\pwsh.exe"
:: Find best PowerShell for admin elevation
set "ELEVATION_PS="
if exist "%PS7_PREVIEW_PATH%" (
set "ELEVATION_PS=%PS7_PREVIEW_PATH%"
) else if exist "%PS7_PATH%" (
set "ELEVATION_PS=%PS7_PATH%"
) else if exist "%PS5_PATH%" (
set "ELEVATION_PS=%PS5_PATH%"
) else (
echo [ERROR] No PowerShell found for elevation!
pause
exit /b 1
)
:: ====================================================
:: Launch with admin rights
:: ====================================================
if "%1"=="admin" goto :AdminMode
echo [INFO] Launch with admin rights...
"%ELEVATION_PS%" -Command "Start-Process cmd -ArgumentList '/c \"%~f0\" admin' -Verb RunAs"
exit /B
:AdminMode
pushd "%CD%"
CD /D "%~dp0"
:: ====================================================
:: Office Privacy and Telemetry Disabler Launcher
:: ====================================================
title Office Privacy and Telemetry Disabler Launcher
:: Set script directory
set "SCRIPT_DIR=%~dp0"
:: Initialize variables
set "PS_EXE="
set "PS_SCRIPT="
set "PS_VERSION="
set "SCRIPT_TYPE="
:: ====================================================
:: Find PowerShell Executable (пріоритет: Preview > 7 > 5)
:: ====================================================
if exist "%PS7_PREVIEW_PATH%" (
set "PS_EXE=%PS7_PREVIEW_PATH%"
set "PS_VERSION=PowerShell 7 Preview"
set "PS_MAJOR=7"
goto :found_powershell
)
if exist "%PS7_PATH%" (
set "PS_EXE=%PS7_PATH%"
set "PS_VERSION=PowerShell 7"
set "PS_MAJOR=7"
goto :found_powershell
)
if exist "%PS5_PATH%" (
set "PS_EXE=%PS5_PATH%"
set "PS_VERSION=PowerShell 5"
set "PS_MAJOR=5"
goto :found_powershell
)
echo [ERROR] No compatible PowerShell version found!
echo.
echo Please install either:
echo - PowerShell 7 Preview (recommended)
echo - PowerShell 7
echo - PowerShell 5 (Windows PowerShell)
echo.
pause
exit /b 1
:found_powershell
:: ====================================================
:: Detect Windows Version
:: ====================================================
for /f "tokens=4-5 delims=. " %%i in ('ver') do (
set "WIN_MAJOR=%%i"
set "WIN_MINOR=%%j"
)
:: ====================================================
:: Choose Script Based on Windows Version AND PowerShell Version
:: ====================================================
if !WIN_MAJOR! GEQ 10 (
if !PS_MAJOR!==5 (
set "SCRIPT_BASENAME=office_privacy_telemetry_disabler_win7+.ps1"
set "SCRIPT_TYPE=Windows 10/11 with PowerShell 5"
) else (
set "SCRIPT_BASENAME=office_privacy_telemetry_disabler.ps1"
set "SCRIPT_TYPE=Windows 10/11 with PowerShell 7"
)
) else (
set "SCRIPT_BASENAME=office_privacy_telemetry_disabler_win7+.ps1"
set "SCRIPT_TYPE=Windows 7/8/8.1"
)
:: ====================================================
:: Locate Script
:: ====================================================
set "SCRIPT_FOUND="
set "TEST_SCRIPT=%SCRIPT_DIR%!SCRIPT_BASENAME!"
if exist "!TEST_SCRIPT!" (
set "PS_SCRIPT=!TEST_SCRIPT!"
set "SCRIPT_FOUND=YES"
goto :script_found
)
set "TEST_SCRIPT=%SCRIPT_DIR%script\!SCRIPT_BASENAME!"
if exist "!TEST_SCRIPT!" (
set "PS_SCRIPT=!TEST_SCRIPT!"
set "SCRIPT_FOUND=YES"
set "SCRIPT_TYPE=!SCRIPT_TYPE! (from script folder)"
goto :script_found
)
echo [ERROR] Expected script !SCRIPT_BASENAME! not found!
echo.
echo Please make sure this script exists:
echo - !SCRIPT_BASENAME!
echo Either in the same folder as this launcher or in the 'script' subfolder.
echo.
pause
exit /b 1
:script_found
:: ====================================================
:: Display Information
:: ====================================================
echo.
echo ====================================================
echo Office Privacy and Telemetry Disabler Launcher
echo.
echo by EXLOUD aka BOBER
echo https://github.com/EXLOUD
echo ====================================================
echo.
echo System Information:
echo - PowerShell: %PS_VERSION%
echo - Script: !SCRIPT_TYPE!
echo - Location: !PS_SCRIPT!
echo.
echo This will disable telemetry and privacy features for:
echo - Microsoft Office 2010-2024
echo - Office logging and telemetry
echo - Customer Experience Improvement Program
echo - Connected Experiences
echo - Automatic updates and notifications
echo - Scheduled telemetry tasks
echo.
:confirmation
set /p "CONFIRM=Do you want to continue? (Y/N): "
if /i "!CONFIRM!"=="y" goto :proceed
if /i "!CONFIRM!"=="yes" goto :proceed
if /i "!CONFIRM!"=="n" goto :cancel
if /i "!CONFIRM!"=="no" goto :cancel
echo Invalid input. Please enter Y or N.
goto :confirmation
:cancel
echo.
echo Operation cancelled by user.
pause
exit /b 0
:proceed
cls
echo.
echo [INFO] Launching Office Privacy Disabler...
echo [INFO] PowerShell: %PS_VERSION%
echo [INFO] Script: !SCRIPT_TYPE!
echo.
echo [WARNING] Administrator rights may be required for some registry changes.
echo.
cd /d "%SCRIPT_DIR%"
"%PS_EXE%" -ExecutionPolicy Bypass -NoProfile -File "!PS_SCRIPT!"
if %errorLevel% == 0 (
echo.
) else (
echo.
echo [ERROR] Script encountered errors. Exit code: %errorLevel%
echo.
echo This may happen if:
echo - Office is not installed
echo - Administrator rights are required
echo - Registry access is restricted
)
echo.
echo Press any key to exit...
pause >nul
exit /b 0