forked from yang123vc/slshim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
uninstall.bat
93 lines (78 loc) · 2.33 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
87
88
89
90
91
92
93
@echo off
set sysdir=%windir%\system32
set offdir=microsoft shared\officesoftwareprotectionplatform
set office=%commonprogramfiles%\%offdir%
if "%PROCESSOR_ARCHITECTURE%"=="AMD64" goto 64BIT
set bits=32
call:checkfiles
call:restorefiles
goto alldone
:64BIT
set bits=64
calL:checkfiles
call:restorefiles
set bits=32
set sysdir=%windir%\syswow64
set office=%commonprogramfiles(x86)%\%offdir%
call:checkfiles
call:restorefiles
goto alldone
:restorefiles
for %%d in (slc,slcext,sppc,sppcext,slwga) do (
set dirname=%sysdir%
set fname=%%d
call:restorefile
)
if not exist "%office%" exit /b
set dirname=%office%
set fname=osppc
call:restorefile
exit /b
:checkfiles
echo === %bits%bit DLLs ===
rem
echo Checking...
for %%d in (slc,slcext,sppc,sppcext,slwga) do (
set dirname=%sysdir%
set fname=%%d
call:checkfile
)
exit /b
:restorefile
set fullname=%dirname%\%fname%
echo - Restoring original %fname%.dll
del "%fullname%.dll"
ren "%fullname%.slold" %fname%.dll
icacls "%fullname%.dll" /setowner "NT SERVICE\TrustedInstaller" 2> nul > nul
icacls "%fullname%.dll" /Grant "NT SERVICE\TrustedInstaller":F 2> nul > nul
exit /b
:checkfile
set fullname=%dirname%\%fname%
if exist "%fullname%.slold" exit /b
echo %fullname%.slold is missing.
echo This can mean two things:
echo.
echo Good: SLShim is not installed at all, hence no backups.
echo Bad: Something deleted the backups.
echo.
echo If you suspect the latter, run sfc /scannow, just to be sure.
echo slshim is designed to become inactive after succesful sfc run.
exit
:alldone
echo.
echo === Deleting SLShim service ====
echo.
rem We let the service live till the very end (so as to keep restored
rem policy backup pinned, despite kernel attempts to put something else there)
sc control SLShim 128
sc delete SLShim
move %windir%\system32\slshim.dll %windir%\Temp\slshim1.%random%.todel > nul 2> nul
move %windir%\syswow64\slshim.dll %windir%\Temp\slshim2.%random%.todel > nul 2> nul
echo.
echo === Re-enabling original SPPSVC ====
echo.
reg add HKLM\SYSTEM\CurrentControlSet\services\sppuinotify /f /v Start /t REG_DWORD /d 2
reg add HKLM\SYSTEM\CurrentControlSet\services\sppsvc /f /v Start /t REG_DWORD /d 3
reg add HKLM\SYSTEM\CurrentControlSet\services\osppsvc /f /v Start /t REG_DWORD /d 3
echo.
echo All done. Reboot now.