Skip to content

soma-code/wsl-auto-launcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WSL Auto Launcher for Windows 10

A Python script that automatically launches Windows Subsystem for Linux (WSL) when Windows starts up.

Features

  • 🚀 Automatically launches WSL on Windows startup
  • 🖥️ Opens WSL in a visible terminal window (Windows Terminal or Command Prompt)
  • 🐧 Ubuntu is the default target distribution (configurable)
  • 📝 Comprehensive logging with rotation
  • ⚙️ Configurable settings
  • 🔧 Multiple startup integration methods (Scheduled Task or Startup Folder)
  • 🛡️ Error handling and retry logic
  • 📊 Support for multiple WSL distributions
  • 🐳 Smart filtering (explicitly excludes Docker Desktop distributions)

Requirements

  • Windows 10 with WSL installed
  • Python 3.6 or higher
  • At least one Linux distribution installed (Ubuntu recommended as default)
  • Docker Desktop WSL distributions are automatically excluded

Installation

  1. Clone or download this project to your preferred directory

  2. Install Python dependencies:

    pip install -r requirements.txt
  3. Test the launcher manually:

    python wsl_launcher.py
  4. Set up automatic startup:

    python startup_setup.py

Configuration

Edit config.py to customize the behavior:

  • STARTUP_DELAY: Time to wait after Windows boot (default: 5 seconds)
  • PREFERRED_DISTRIBUTION: Specific WSL distribution to launch (leave empty for Ubuntu default)
  • ENABLE_LOGGING: Enable/disable detailed logging
  • MAX_LAUNCH_ATTEMPTS: Number of retry attempts
  • HIDE_CONSOLE: Hide console window when running
  • OPEN_TERMINAL_WINDOW: Open visible terminal window when launching WSL (default: True)

Note: The script defaults to launching Ubuntu but will launch the first available non-Docker distribution if Ubuntu is not installed. Docker Desktop distributions (docker-desktop, docker-desktop-data) are always excluded to allow Docker to manage them independently.

Usage

Manual Launch

python wsl_launcher.py

Setup Automatic Startup

python startup_setup.py

Choose from:

  1. Scheduled Task (Recommended) - More reliable, runs even if user isn't logged in
  2. Startup Folder Shortcut - Simpler but only runs when user logs in

Remove Automatic Startup

Run the setup script again and choose option 3 to remove the automatic startup.

How It Works

  1. Startup Integration: The script integrates with Windows startup using either:

    • Windows Task Scheduler (recommended)
    • Startup folder shortcut
  2. WSL Detection: Checks if WSL is installed and available

  3. Distribution Discovery: Finds all installed WSL distributions

  4. Launch Process: Launches WSL with a visible terminal window using Windows Terminal (preferred) or Command Prompt

  5. Docker Filtering: Automatically excludes Docker Desktop distributions (docker-desktop, docker-desktop-data) from launch candidates, allowing Docker to manage its own WSL instances independently

  6. Logging: Records all activities to a log file for troubleshooting

Troubleshooting

Check if WSL is running:

wsl --list --running

View logs:

Logs are stored in: %USERPROFILE%\AppData\Local\WSLLauncher\wsl_launcher.log

Common Issues:

  1. "WSL is not installed": Install WSL from Microsoft Store or PowerShell
  2. "No user WSL distributions found": Install Ubuntu or another Linux distribution from Microsoft Store
  3. Permission errors: Run PowerShell as Administrator for initial setup
  4. Docker distributions showing: This is normal - Docker Desktop distributions are intentionally excluded and managed separately

Manual WSL Commands:

# List all WSL distributions
wsl --list --verbose

# Launch specific distribution
wsl -d Ubuntu-20.04

# Check WSL status
wsl --status

File Structure

wsl-script/
├── wsl_launcher.py      # Main launcher script
├── startup_setup.py     # Windows startup integration
├── config.py           # Configuration settings
├── requirements.txt    # Python dependencies
└── README.md          # This file

License

This project is open source and available under the MIT License.

Contributing

Feel free to submit issues, feature requests, or pull requests to improve this tool.


Note: This tool is designed for Windows 10 with WSL and targets Ubuntu by default (configurable). Docker Desktop WSL distributions are explicitly excluded and should be managed through Docker Desktop itself. Make sure WSL is properly installed and configured before using this launcher.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages