This repository has been archived by the owner on Jul 15, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
SM_AutoUpdate.bat
121 lines (121 loc) · 3.56 KB
/
SM_AutoUpdate.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
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
@echo off
:main
setlocal enabledelayedexpansion
set v=1.0
title ServerMod Updater v!v!
set "scp_appdata=%appdata%\SCP Secret Laboratory"
set "data=%~dp0\SCPSL_Data\Managed"
echo.
if exist "%~dp0LocalAdmin.exe" (
if not exist "!data!" (
echo Unable to locate 'SCPSL_Data\Managed'.
echo Make sure you are running the latest version of SCPSL.
pause > nul
endlocal
exit
)
) else (
echo "I have no memory of this place..." - Gandalf, 2069
echo ^('%~dp0' is probably not the correct location^)
echo.
echo %~n0 is not running from the SCP:SL server root.
echo Find the correct location and retry.
pause > nul
endlocal
exit
)
echo Downloading version data...
if exist "!scp_appdata!\n_sm_version.md" (
del /q "!scp_appdata!\n_sm_version.md" > nul
)
bitsadmin /create /download "sm_version" > nul
bitsadmin /setnoprogresstimeout "sm_version" > nul
bitsadmin /transfer "sm_version" "https://raw.githubusercontent.com/lordofkhaos/SM_AutoUpdate/master/sm_version.md" "!scp_appdata!\n_sm_version.md" > nul
if !errorlevel!==0 (
bitsadmin /complete "sm_version" > nul
) else (
echo Download failed.
echo.
echo Press any key to retry.
pause > nul
bitsadmin /complete "sm_version" > nul
endlocal
goto :main
)
echo Done.
echo.
echo Parsing version data...
if exist "!scp_appdata!\sm_version.md" (
for /f "usebackq tokens=2 delims==" %%A in ("!scp_appdata!\sm_version.md") do (
set "local_version=%%A"
set _local_version=!local_version:.=!
)
) else (
echo No local version data found.
echo.
echo Press any key to update regardless.
pause > nul
for /f "usebackq tokens=2 delims==" %%A in ("!scp_appdata!\n_sm_version.md") do (
set "sm_version=%%A"
set _sm_version=!sm_version:.=!
)
goto :update
)
for /f "usebackq tokens=2 delims==" %%A in ("!scp_appdata!\n_sm_version.md") do (
set "sm_version=%%A"
set _sm_version=!sm_version:.=!
)
echo Done.
echo.
if !_local_version! LSS !_sm_version! (
echo.
echo A newer version of ServerMod is available.
echo.
echo Your version: !local_version!
echo New version: !sm_version!
echo.
echo Press any key to download.
pause > nul
goto :update
) else (
echo.
echo Your ServerMod is up to date. ^(Local: v!local_version! Online: v!sm_version!^)
echo.
echo Press any key to exit.
pause > nul
endlocal
exit
)
:update
cls
echo Preparing download...
tasklist /fi "IMAGENAME eq SCPSL.exe" | find /i "SCPSL.exe" > nul
if !errorlevel!==0 (
echo.
echo Cannot download while SCP:SL is running.
echo Exit SCP:SL and try again.
pause > nul
endlocal
exit
)
set "smod_link=https://github.com/Grover-c13/Smod/releases/download/%sm_version%/Smod2.dll"
set "assembly_link=https://github.com/Grover-c13/Smod/releases/download/%sm_version%/Assembly-CSharp.dll"
echo Downloading required files...
powershell -command "& { $tls12 = [Enum]::ToObject([Net.SecurityProtocolType], 3072); [Net.ServicePointManager]::SecurityProtocol = $tls12; (New-Object Net.WebClient).DownloadFile('!smod_link!', '!data!\Smod2.dll') }"
powershell -command "& { $tls12 = [Enum]::ToObject([Net.SecurityProtocolType], 3072); [Net.ServicePointManager]::SecurityProtocol = $tls12; (New-Object Net.WebClient).DownloadFile('!assembly_link!', '!data!\Assembly-CSharp.dll') }"
if exist "!data!\Smod2.dll" && "!data!\Assembly-CSharp.dll" (
echo Done.
echo Now running v!sm_version!
) else (
echo Download failed.
echo.
echo Press any key to retry.
pause > nul
goto :update
)
echo.
echo.
echo Press any key to exit
pause > nul
endlocal
exit