-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIMPORT-SDK.bat
63 lines (54 loc) · 2.06 KB
/
IMPORT-SDK.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
@echo off
setlocal enabledelayedexpansion
:: SETTINGS
if defined ProgramFiles(x86) (set SYSTEM_BITS=64) else set SYSTEM_BITS=86
set "SDK_LOCATION=%appdata%\SDK"
:: [END] SETTINGS
call :IMPORT_SDK && (
echo INFO: Installed SDK.
echo INFO: Starting SDK.
for /f "delims=" %%a in ('call "!SDK_CORE!" --curl "!SDK_CURL!" --install-location "!SDK_LOCATION!"') do set %%a
)
REM Your Script here
exit /b
:: <IMPORT SDK>
:IMPORT_SDK
set SDK_CURL=
if not exist "!SDK_LOCATION!" md "!SDK_LOCATION!"
for /f "delims=" %%a in ('2^>nul where curl.exe ^|^| echo 1') do (
if %%a neq 1 (
call :VALIDATE_CURL_INSTALLATION "%%a" && set "SDK_CURL=%%a"
) else (
if exist "!SDK_LOCATION!\curl.exe" call :VALIDATE_CURL_INSTALLATION "!SDK_LOCATION!\curl.exe" && set "SDK_CURL=!SDK_LOCATION!\curl.exe"
)
)
if not defined SDK_CURL call :IMPORT_CURL || exit /b 1
set "SDK_CORE=%SDK_LOCATION%\SDK.bat"
if not exist "!SDK_CORE!" call "!SDK_CURL!" -L#sko "!SDK_CORE!" "https://raw.githubusercontent.com/agamsol/SDK/latest/SDK.bat"
exit /b 0
:: </IMPORT SDK>
:: <IMPORT CURL>
:IMPORT_CURL
for /f "delims=" %%a in ("https://github.com/agamsol/SDK/raw/latest/curl/x!SYSTEM_BITS!/curl.exe") do (
set "SDK_CURL=!SDK_LOCATION!\curl.exe"
>nul chcp 437
>nul 2>&1 powershell /? && (
>nul 2>&1 powershell $progressPreference = 'silentlyContinue'; Invoke-WebRequest -Uri "'%%~a'" -OutFile "'!SDK_CURL!'"
>nul chcp 65001
call :VALIDATE_CURL_INSTALLATION "!SDK_CURL!" && exit /b 0
)
>nul chcp 65001
>nul bitsadmin /transfer someDownload /download /priority high "%%~a" "!SDK_CURL!"
call :VALIDATE_CURL_INSTALLATION "!SDK_CURL!" && exit /b 0
>nul certutil -urlcache -split -f "%%~a" "!SDK_CURL!"
call :VALIDATE_CURL_INSTALLATION "!SDK_CURL!" && exit /b 0
)
exit /b 1
:VALIDATE_CURL_INSTALLATION "[CURL]"
if not exist "%~1" exit /b 1
call "%~1" --version | findstr /brc:"curl [0-9]*\.[0-9]*\.[0-9]*">nul || (
>nul 2>&1 del /s /q "%~1"
exit /b 1
)
exit /b 0
:: </IMPORT CURL>