-
Notifications
You must be signed in to change notification settings - Fork 0
/
uninstall.bat
86 lines (70 loc) · 2.26 KB
/
uninstall.bat
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
@echo off
:: Get admin permissions
SET "params=%*"
CD /D "%~dp0"
IF EXIST "%temp%\getadmin.vbs" (
DEL /Q "%temp%\getadmin.vbs"
)
FSUTIL DIRTY QUERY %systemdrive% 1>nul 2>nul || (
ECHO SET UAC = CreateObject^("Shell.Application"^) : UAC.ShellExecute "cmd.exe", "/K CD ""%~sdp0"" && %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
EXIT /B
)
:: Task names to delete
set "batteryTaskName=BATTERY"
set "batterySleepTaskName=BATTERY-SLEEP"
:: Delete the tasks from Task Scheduler
schtasks /delete /tn "%batteryTaskName%" /f
if %errorlevel% neq 0 (
echo Error: Deleting task "%batteryTaskName%".
pause
exit /b 1
)
schtasks /delete /tn "%batterySleepTaskName%" /f
if %errorlevel% neq 0 (
echo Error: Deleting task "%batterySleepTaskName%".
pause
exit /b 1
)
echo Success: Scheduled Tasks deleted.
:: Check if powershell.exe is running
tasklist /FI "IMAGENAME eq powershell.exe" | find /I "powershell.exe" >nul
if %ERRORLEVEL% EQU 0 (
TASKKILL /IM "powershell.exe" /F
if %ERRORLEVEL% NEQ 0 (
echo Error: Failed to terminate powershell.exe.
pause
exit /b 1
)
TIMEOUT /T 2 /NOBREAK
)
:: Clean up files
set "idFile=%~dp0battery_id.txt"
set "tokenFile=%~dp0battery_token.txt"
set "logsDir=%~dp0logs\"
if exist "%idFile%" (
del /q "%idFile%"
)
if exist "%tokenFile%" (
del /q "%tokenFile%"
)
if exist "%logsDir%" (
rd /s /q "%logsDir%"
)
echo Success: Cleaned up files.
:: Remove registry entries for Group Policy Scripts
reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts\Shutdown\0\0" /f
reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts\Shutdown\0" /f
reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\Scripts\Shutdown\0\0" /f
reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\Scripts\Shutdown\0" /f
set "iniFile=%WINDIR%\System32\GroupPolicy\Machine\Scripts\scripts.ini"
if exist "%iniFile%" (
attrib -h "%iniFile%"
del /q "%iniFile%"
)
:: Force a Group Policy update
gpupdate /force
echo Success: Group Policy Task deleted.
echo Uninstall Complete.
pause
exit /b 0