Skip to content

Commit c2e313c

Browse files
committed
Add single install scripts
1 parent 7de3eb6 commit c2e313c

File tree

3 files changed

+307
-0
lines changed

3 files changed

+307
-0
lines changed

dists/install1.bat

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
@rem v3.5.2 This script install patch for android ndk(x64) and android sdk tools's .exe
2+
@echo off
3+
4+
:: BatchGotAdmin
5+
:-------------------------------------
6+
REM --> Check for permissions
7+
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
8+
9+
REM --> If error flag set, we do not have admin.
10+
if '%errorlevel%' NEQ '0' (
11+
echo Requesting administrative privileges...
12+
goto UACPrompt
13+
) else ( goto gotAdmin )
14+
15+
:UACPrompt
16+
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
17+
echo UAC.ShellExecute "cmd.exe", "/c %~s0 %*", "", "runas", 1 >> "%temp%\getadmin.vbs"
18+
19+
"%temp%\getadmin.vbs"
20+
del "%temp%\getadmin.vbs"
21+
exit /B
22+
23+
:gotAdmin
24+
pushd %cd%
25+
cd /d "%~dp0"
26+
27+
set instDir=%~dp1
28+
set instApp=%~nx1
29+
30+
set realAppPrefix=wrl-
31+
32+
echo [wsls] Installing ...
33+
34+
set X86HASH=
35+
set X64HASH=
36+
for /f "delims=" %%i in ('wsls-hash "x86/wsls-shell.exe"') do set X86HASH=%%i
37+
for /f "delims=" %%i in ('wsls-hash "x64/wsls-shell.exe"') do set X64HASH=%%i
38+
39+
echo X86HASH=%X86HASH%
40+
echo X64HASH=%X64HASH%
41+
42+
rem Install wsls core binaires
43+
del /q %WINDIR%\System32\wsLongPaths.dll 2>nul
44+
if exist %WINDIR%\SysWow64\ (
45+
del /q %WINDIR%\SysWow64\wsLongPaths.dll 2>nul
46+
47+
copy /y x64\wow64helper.exe %WINDIR%\System32\
48+
copy /y x64\wsls-core.dll %WINDIR%\System32\
49+
50+
copy /y x86\wow64helper.exe %WINDIR%\SysWow64\
51+
copy /y x86\wsls-core.dll %WINDIR%\SysWow64\
52+
) else (
53+
copy /y x86\wow64helper.exe %WINDIR%\System32\
54+
copy /y x86\wsls-core.dll %WINDIR%\System32\
55+
)
56+
57+
rem clear errorlevel before starting install patch
58+
set errorlevel=
59+
60+
rem patching make.exe & cmp.exe
61+
call :InstallPatch %instDir% %instApp%
62+
63+
REM exit install.bat script
64+
:L_exit
65+
echo Exiting install.bat...&ping /n 2 127.0.1 >nul
66+
goto :eof
67+
68+
rem --------------------- the InstalPatch subprocedure ----------------
69+
rem <params>
70+
rem <instDir>The target .exe directory</instDir>
71+
rem <instApp>The target .exe</instApp>
72+
rem <arch>The arch of target, optional: if not specific, will auto detect</arch>
73+
rem <redApp>The redirect App, don't use original of ndk, such as gnumake.exe</redApp>
74+
rem </params>
75+
:InstallPatch
76+
set instDir=%1
77+
set instApp=%2
78+
set arch=%3
79+
set redApp=%4
80+
81+
rem -------- check parameters ------
82+
83+
rem -- clear parameter value if nil
84+
if "%arch%"=="nil" set arch=
85+
if "%redApp%"=="nil" set redApp=
86+
87+
rem if the arch undefined or nil, detect it auto
88+
setlocal ENABLEDELAYEDEXPANSION
89+
set errorlevel=
90+
91+
rem Notes: ensure always detect arch from real app, this will auto fix previous release 3.4.x arch mismatch bug
92+
if not defined arch (
93+
if exist "%instDir%\%realAppPrefix%%instApp%" (
94+
call wsls-arch.exe "%instDir%\%realAppPrefix%%instApp%"
95+
if !errorlevel! GTR 0 set arch=x!errorlevel!
96+
) else (
97+
call wsls-arch.exe "%instDir%\%instApp%"
98+
if !errorlevel! GTR 0 set arch=x!errorlevel!
99+
)
100+
)
101+
102+
set errorlevel=
103+
setlocal DISABLEDELAYEDEXPANSION
104+
105+
if not "%arch%"=="x86" (
106+
if not "%arch%"=="x64" (
107+
echo Skipping target %instDir%\%instApp% with arch '%arch%', valid arch list: x86,x64 && goto :eof
108+
)
109+
)
110+
111+
rem -- print parameters
112+
rem echo instDir="%instDir%"
113+
rem echo instApp="%instApp%"
114+
rem echo arch="%arch%"
115+
rem echo redApp="%redApp%"
116+
117+
rem custom such as gnumake.exe
118+
if defined redApp (
119+
copy /y %arch%\%redApp% "%instDir%\%redApp%"
120+
if exist %arch%\%instApp%.bridge copy /y %arch%\%instApp%.bridge "%instDir%\%instApp%.bridge"
121+
)
122+
123+
set instHash=
124+
for /f "delims=" %%i in ('wsls-hash "%instDir%\%instApp%"') do set instHash=%%i
125+
126+
if "%arch%"=="x64" (
127+
if "%instHash%"=="%X64HASH%" goto :L_installed
128+
) else (
129+
if "%instHash%"=="%X86HASH%" goto :L_installed
130+
)
131+
132+
echo Installing patch for %instApp%(%arch%)...
133+
134+
rem --- perform install
135+
rem make a copy of original xxx.exe to wrl-xxx.exe
136+
if not exist "%instDir%\%realAppPrefix%%instApp%" copy /y "%instDir%\%instApp%" "%instDir%\%realAppPrefix%%instApp%"
137+
138+
copy /y %arch%\wsls-shell.exe "%instDir%\%instApp%"
139+
140+
echo Install patch for %instApp%(%arch%) succeed.
141+
goto :eof
142+
143+
:L_installed
144+
echo The patch for %instApp%(%arch%) already installed.
145+
goto :eof

dists/uninstall0.bat

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
@REM v3.5.2 This script uninstall wsls core binaries
2+
@REM uninstall0.bat
3+
@echo off
4+
:: BatchGotAdmin
5+
::-------------------------------------
6+
REM --> Check for permissions
7+
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
8+
9+
REM --> If error flag set, we do not have admin.
10+
if '%errorlevel%' NEQ '0' (
11+
echo Requesting administrative privileges...
12+
goto UACPrompt
13+
) else ( goto gotAdmin )
14+
15+
:UACPrompt
16+
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
17+
echo UAC.ShellExecute "cmd.exe", "/c %~s0 %*", "", "runas", 1 >> "%temp%\getadmin.vbs"
18+
19+
"%temp%\getadmin.vbs"
20+
del "%temp%\getadmin.vbs"
21+
exit /B
22+
23+
:gotAdmin
24+
pushd %cd%
25+
cd /d "%~dp0"
26+
27+
del /q /f %WINDIR%\System32\wsLongPaths.dll 2>nul
28+
if exist %WINDIR%\SysWow64\ (
29+
del /q /f %WINDIR%\SysWow64\wsLongPaths.dll 2>nul
30+
31+
del /q /f %WINDIR%\System32\wsls-copy.exe 2>nul
32+
del /q /f %WINDIR%\System32\wsls-del.exe 2>nul
33+
del /q /f %WINDIR%\System32\wsls-md.exe 2>nul
34+
del /q /f %WINDIR%\System32\wow64helper.exe 2>nul
35+
del /q /f %WINDIR%\System32\wsls-core.dll 2>nul
36+
37+
del /q /f %WINDIR%\SysWow64\wsls-copy.exe 2>nul
38+
del /q /f %WINDIR%\SysWow64\wsls-del.exe 2>nul
39+
del /q /f %WINDIR%\SysWow64\wsls-md.exe 2>nul
40+
del /q /f %WINDIR%\SysWow64\wow64helper.exe 2>nul
41+
del /q /f %WINDIR%\SysWow64\wsls-core.dll 2>nul
42+
) else (
43+
del /q /f %WINDIR%\System32\wsls-copy.exe 2>nul
44+
del /q /f %WINDIR%\System32\wsls-del.exe 2>nul
45+
del /q /f %WINDIR%\System32\wsls-md.exe 2>nul
46+
del /q /f %WINDIR%\System32\wow64helper.exe 2>nul
47+
del /q /f %WINDIR%\System32\wsls-core.dll 2>nul
48+
)
49+
50+
REM exit uninstall0.bat script
51+
:L_exit
52+
echo Done, exiting uninstall0.bat...&ping /n 2 127.0.1 >nul
53+
goto :eof

dists/uninstall1.bat

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
@REM v3.5.2 This script uninstall patch for any exe.
2+
@REM Usage: drag target exe to this script on explorer or
3+
@REM uninstall1 D:\xxx\xxx.exe
4+
5+
@echo off
6+
cd /d %~dp0
7+
8+
set instDir=%~dp1
9+
set instApp=%~nx1
10+
11+
echo Uninstalling `%instApp%` in `%instDir%` ...
12+
13+
set realAppPrefix=wrl-
14+
15+
set X86HASH=
16+
set X64HASH=
17+
for /f "delims=" %%i in ('wsls-hash "x86/wsls-shell.exe"') do set X86HASH=%%i
18+
for /f "delims=" %%i in ('wsls-hash "x64/wsls-shell.exe"') do set X64HASH=%%i
19+
20+
echo X86HASH=%X86HASH%
21+
echo X64HASH=%X64HASH%
22+
23+
REM clear errorlevel before starting install patch
24+
set errorlevel=
25+
26+
REM uninstall patch for app(xxx.exe)
27+
call :UninstallPatch %instDir% %instApp% nil
28+
29+
REM exit uninstall.bat script
30+
:L_exit
31+
echo Exiting uninstall.bat...&ping /n 2 127.0.1 >nul
32+
goto :eof
33+
34+
REM --------------------- the InstalPatch subprocedure ----------------
35+
REM <params>
36+
REM <instDir>The target .exe directory</instDir>
37+
REM <instApp>The target .exe</instApp>
38+
REM <arch>The arch of target, optional: if not specific, will auto detect</arch>
39+
REM <redApp>The redirect App, don't use original of ndk, such as gnumake.exe</redApp>
40+
REM </params>
41+
:UninstallPatch
42+
set instDir=%1
43+
set instApp=%2
44+
set arch=%3
45+
set redApp=%4
46+
47+
REM -- clear parameters
48+
if "%arch%"=="nil" set arch=
49+
if "%redApp%"=="nil" set redApp=
50+
51+
REM if the arch undefined or nil, detect it auto
52+
setlocal ENABLEDELAYEDEXPANSION
53+
set errorlevel=
54+
55+
REM Notes: ensure always detect arch from real app, this will auto fix previous release 3.4.x arch mismatch bug
56+
if not defined arch (
57+
if exist "%instDir%\%realAppPrefix%%instApp%" (
58+
call wsls-arch.exe "%instDir%\%realAppPrefix%%instApp%"
59+
if !errorlevel! GTR 0 set arch=x!errorlevel!
60+
) else (
61+
call wsls-arch.exe "%instDir%\%instApp%"
62+
if !errorlevel! GTR 0 set arch=x!errorlevel!
63+
)
64+
)
65+
66+
set errorlevel=
67+
setlocal DISABLEDELAYEDEXPANSION
68+
69+
if not "%arch%"=="x86" (
70+
if not "%arch%"=="x64" (
71+
echo Skipping target %instDir%\%instApp% with arch '%arch%', valid arch list: x86,x64 && goto :eof
72+
)
73+
)
74+
75+
REM -- print parameters
76+
REM echo instDir="%instDir%"
77+
REM echo instApp="%instApp%"
78+
REM echo arch="%arch%"
79+
REM echo redApp="%redApp%"
80+
81+
REM custom such as gnumake.exe
82+
if defined redApp (
83+
if exist "%instDir%\%redApp%" del del /q /s /f "%instDir%\%redApp%"
84+
if exist "%instDir%\%instApp%.bridge" del "%instDir%\%instApp%.bridge"
85+
)
86+
87+
set instHash=
88+
for /f "delims=" %%i in ('wsls-hash "%instDir%\%instApp%"') do set instHash=%%i
89+
90+
if "%arch%"=="x64" (
91+
if not "%instHash%"=="%X64HASH%" goto :L_not_installed
92+
) else (
93+
if not "%instHash%"=="%X86HASH%" goto :L_not_installed
94+
)
95+
96+
echo Uninstalling patch for %instApp%(%arch%)...
97+
98+
REM --- perform uninstall
99+
if exist "%instDir%\%realAppPrefix%%instApp%" (
100+
del /q /f "%instDir%\%instApp%"
101+
move /Y "%instDir%\%realAppPrefix%%instApp%" "%instDir%\%instApp%"
102+
)
103+
104+
echo Uninstall patch for %instApp%(%arch%) succeed.
105+
goto :eof
106+
107+
:L_not_installed
108+
echo "The patch for %instApp%(%arch%) not installed."
109+
goto :eof

0 commit comments

Comments
 (0)