Skip to content

Instantly share code, notes, and snippets.

@ulayera
Created August 21, 2025 03:05
Show Gist options
  • Select an option

  • Save ulayera/52b0580d7ff310b4bc33e773ff504257 to your computer and use it in GitHub Desktop.

Select an option

Save ulayera/52b0580d7ff310b4bc33e773ff504257 to your computer and use it in GitHub Desktop.
@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