From 3c8c26c55162f9d88af62cc21d6b69fb605709fc Mon Sep 17 00:00:00 2001 From: LoganDark Date: Thu, 13 May 2021 06:12:32 +0200 Subject: [PATCH] Add flags and stuff to batch script --- install-wsl.bat | 96 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 95 insertions(+), 1 deletion(-) diff --git a/install-wsl.bat b/install-wsl.bat index 5af92c1..755e018 100644 --- a/install-wsl.bat +++ b/install-wsl.bat @@ -1,2 +1,96 @@ @echo off -powershell.exe -ExecutionPolicy ByPass "Import-Module %~dp0install-wsl.psm1; Install-WSLInteractive; pause" \ No newline at end of file + +if not "%1"=="" ( + if "%1"=="--help" ( + goto help + ) + + if "%1"=="--install" ( + if not "%2"=="" ( + if "%3"=="" ( + set extra=" -InformationAction Continue" + ) else ( + if "%3"=="--quiet" ( + set extra=" -InformationAction SilentlyContinue" + ) else ( + goto help + ) + ) + + if "%2"=="wslubuntu2004" ( goto :install ) + if "%2"=="wslubuntu2004arm" ( goto :install ) + if "%2"=="wsl-ubuntu-1804" ( goto :install ) + if "%2"=="wsl-ubuntu-1804-arm" ( goto :install ) + if "%2"=="wsl-ubuntu-1604" ( goto :install ) + if "%2"=="wsl-debian-gnulinux" ( goto :install ) + if "%2"=="wsl-kali-linux-new" ( goto :install ) + if "%2"=="wsl-opensuse-42" ( goto :install ) + if "%2"=="wsl-sles-12" ( goto :install ) + ) + + goto :help + ) + + if "%1"=="--cancel" ( + if "%2"=="" ( + set extra=" -InformationAction Continue" + ) else ( + if "%2"=="--quiet" ( + set extra=" -InformationAction SilentlyContinue" + ) else ( + goto help + ) + ) + + goto :cancel + ) + + if "%1"=="--windows-terminal" ( + goto windowsterminal + ) + + goto help +) + +goto default + +:help +echo A wrapper script to help run the WSL installation with minimal effort. +echo. +echo Usage: install-wsl.bat --help +echo Displays all possible invocations of this script and brief descriptions of +echo each. +echo. +echo Usage: install-wsl.bat --install [--quiet] +echo Installs the given distribution. If the --quiet flag is given then no output +echo will be printed. +echo. +echo Valid distributions: +echo wslubuntu2004, wslubuntu2004arm, wsl-ubuntu-1804, wsl-ubuntu-1804-arm, +echo wsl-ubuntu-1604, wsl-debian-gnulinux, wsl-kali-linux-new, wsl-opensuse-42, +echo wsl-sles-12 +echo. +echo Usage: install-wsl.bat --cancel [--quiet] +echo Cancels all pending installs. If the --quiet flag is given then no output +echo will be printed. +echo. +echo Usage: install-wsl.bat --windows-terminal +echo Installs Windows Terminal using scoop. +goto end + +:install +powershell.exe -ExecutionPolicy ByPass "Import-Module %~dp0install-wsl.psm1; $a = Install-WSL -LinuxDistribution %2%extra%" +goto end + +:cancel +powershell.exe -ExecutionPolicy ByPass "Import-Module %~dp0install-wsl.psm1; $a = Install-WSL -Cancel%extra%" +goto end + +:windowsterminal +powershell.exe -ExecutionPolicy ByPass "Import-Module %~dp0install-wsl.psm1; $a = Install-WSL -InstallWindowsTerminal%extra%" +goto end + +:default +powershell.exe -ExecutionPolicy ByPass "Import-Module %~dp0install-wsl.psm1; $a = Install-WSLInteractive" + +:end \ No newline at end of file