-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcheck-powershell-download.bat
20 lines (17 loc) · 1.11 KB
/
check-powershell-download.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
@if "%PATH:~-1%" == "\" set "PATH=%PATH:~0,-1%"
@echo off
where msr.exe 2>nul >nul || if not exist %~dp0\msr.exe powershell -Command "$ProgressPreference = 'SilentlyContinue'; [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -Uri https://github.com/qualiu/msr/blob/master/tools/msr.exe?raw=true -OutFile %~dp0\msr.exe"
where msr.exe 2>nul >nul || set "PATH=%~dp0;%PATH%"
msr -z "X%~1" -it "^X(|-h|--help|/\?)$" >nul
if !ERRORLEVEL! EQU 1 (
echo Usage: %0 IsPreview
echo Example: %0 1
echo Example: %0 0
exit /b -1
)
:: Replace if not preview
if "%~1" == "0" (
msr -rp %~dp0 -f "\.bat$" --nt "SecurityProtocol" -x OutFile -it "Invoke-WebRequest" -o "$ProgressPreference = 'SilentlyContinue'; [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $0" -e Command -R
) else (
msr -rp %~dp0 -f "\.bat$" --nt "SecurityProtocol" -x OutFile -it "Invoke-WebRequest" -o "$ProgressPreference = 'SilentlyContinue'; [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $0" -e Command
)