Created
August 21, 2025 03:05
-
-
Save ulayera/52b0580d7ff310b4bc33e773ff504257 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @echo off | |
| set WSL_UTF8=1 | |
| goto main | |
| REM Function to check WSL status | |
| :check_status | |
| wsl -l --running | FINDSTR Ubuntu >nul 2>&1 | |
| if %errorlevel% equ 0 ( | |
| set "STATUS=running" | |
| ) else ( | |
| set "STATUS=down" | |
| ) | |
| goto :eof | |
| REM Function to start distro | |
| :start_distro | |
| wsl --exec dbus-launch true | |
| if %errorlevel% equ 0 ( | |
| echo %DATE% %TIME% started | |
| ) else ( | |
| echo %DATE% %TIME% failed to start (error code: %errorlevel%) | |
| ) | |
| goto :eof | |
| REM Main logic | |
| :main | |
| call :check_status | |
| if "%STATUS%"=="running" ( | |
| echo %DATE% %TIME% running | |
| ) else ( | |
| echo %DATE% %TIME% down, trying to start | |
| call :start_distro | |
| ) | |
| timeout /t 5 /nobreak >nul | |
| goto main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment