WIP
authorAbdullah Leghari <leghari.k@gmail.com>
Fri, 8 May 2020 21:21:27 +0000 (02:21 +0500)
committerAJ ONeal <coolaj86@gmail.com>
Tue, 30 Jun 2020 02:52:17 +0000 (20:52 -0600)
_example/install.bat

index a8c9bad94f314d59f723270f124bcb67451e94df..69d720a6f9be2f728146f69f22c2860f031fba00 100644 (file)
@@ -1 +1,50 @@
 rem TODO
+@echo off
+rem get OS version
+for /f "tokens=4-5 delims=. " %%i in ('ver') do set VERSION=%%i.%%j
+if "%version%" == "6.3" set currentOS=win8.1
+if "%version%" == "6.2" set currentOS=win8
+if "%version%" == "6.1" set currentOS=win7
+if "%version%" == "6.0" set currentOS=winVista
+if "%version%" == "10.0" set currentOS=win10
+
+rem get this Computer Architecture
+set currentArch=%processor_architecture%
+
+
+echo This PC OS = %currentOS%
+echo This PC arch = %currentArch%
+
+set pkg=node
+set ver=12
+
+
+rem invoke PowerShell to fetch CSV from the page on URL
+for /f "tokens=*" %%i in ('powershell.exe -command "(Invoke-WebRequest -URI 'https://webinstall.dev/api/releases/%pkg%@%ver%.csv?os=%currentOS%&arch=%currentArch%&channel=stable&ext=zip&limit=1').Content"') do set return=%%i
+
+rem Break apart the CSV returned by the webpage on URL
+for /F "tokens=1-9 delims=," %%a in ("%return%") do (
+set version=%%a
+set pkg_url=%%i
+set os=%%e
+set arch=%%f
+)
+
+rem Break apart parts of pkg_url to file name & directory
+for /F "tokens=1-5 delims=/" %%a in ("%pkg_url%") do (
+set pkg_file=%%e
+set pkg_dir=%%c
+)
+
+
+
+rem Final variable names as below.
+echo Reurned CSV = %return% & echo.
+echo Version = %version%
+echo Url = %pkg_url%
+echo pkg_file = %pkg_file%
+echo pkg_dir = %pkg_dir%
+echo os in CSV = %os%
+echo arch in CSV = %arch%
+echo this PC OS = %currentOS%
+echo this PC arch = %currentArch%