The Founder’s Guide:

How to Run WSL2 at Startup on Windows

The condensed version with copy and paste code and screenshots

David Littlefield
4 min readDec 2, 2020
Image by Bram Van Oost

“The expanded version of this article uses concise explanations to help you learn what’s happening 💡”

Open PowerShell:

  1. Press “⊞ Windows”
  2. Enter “PowerShell” into the search bar
  3. Click “Run as Administrator”

Create the Visual Basic Script File:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
echo "" > $HOME\run_wsl2_at_startup.vbs

Open the Visual Basic Script File:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
notepad $HOME\run_wsl2_at_startup.vbs

Edit the Visual Basic Script File:

  1. Find the Ubuntu version from below these instructions
  2. Copy the provided code
  3. Paste the code into Notepad
  4. Click the “File” menu
  5. Click “Save”
Ubuntu 20.04:
set object = createobject("wscript.shell")
object.run "wsl.exe --distribution Ubuntu-20.04", 0
Ubuntu 18.04:
set object = createobject("wscript.shell")
object.run "wsl.exe --distribution Ubuntu-18.04", 0

Open Task Scheduler:

  1. Press “⊞ Windows”
  2. Enter “Task Scheduler” into the search bar
  3. Click “Task Scheduler”

Create the Task:

  1. Click “Create Basic Task” in the right panel
  2. Copy the text from below these instructions
  3. Paste the text into the “Name” text field
  4. Click “Next”
  5. Select “When the Computer Starts”
  6. Click “Next”
  7. Select “Start a Program”
  8. Click “Next”
Windows Subsystem for Linux 2 (WSL2)

Specify the Action:

  1. Copy the path from below these instructions
  2. Paste the path into the “Program/Script” text field
  3. Click “Next”
  4. Click “Yes”
  5. Check “Open the Properties Dialog…”
  6. Click “Finish”
%USERPROFILE%\run_wsl2_at_startup.vbs

Specify the Trigger:

  1. Click “Triggers” in the top tab bar
  2. Click “At Startup”
  3. Click “Edit”
  4. Check “Delay Task For”
  5. Enter “30 Seconds”
  6. Click “OK”

Run in the Background:

  1. Click “General” in the tab bar
  2. Select “Run Whether User Is Logged On or Not”
  3. Check “Run With Highest Privileges”

Remove the Time Limit:

  1. Click “Settings” in the tab bar
  2. Uncheck “Stop the Task if It Runs Longer Than”
  3. Click “OK”
  4. Restart the computer

Open PowerShell:

  1. Press “⊞ Windows”
  2. Enter “PowerShell” into the search bar
  3. Click “Run as Administrator”

Get Running Processes:

  1. Copy the command from below these instructions
  2. Paste the command into PowerShell
  3. Press “Enter”
get-process

Bonus: Run a Program At Startup:

  1. Find the Ubuntu version from below these instructions
  2. Replace the “Program” with the program name
  3. Replace the “Arguments” with the arguments
  4. Copy the provided code
  5. Paste the code into Notebook
  6. Click the “File” menu
  7. Click “Save”
Ubuntu 20.04:
set object = createobject("wscript.shell")
object.run "wsl.exe --distribution Ubuntu-20.04 program arguments", 0
Ubuntu 18.04:
set object = createobject("wscript.shell")
object.run "wsl.exe --distribution Ubuntu-18.04 program arguments", 0

“Hopefully, this article helped you get the 👯‍♀️🏆👯‍♀️, remember to subscribe to get more content 🏅”

Next Steps: AI, Machine Learning, and Deep Learning

This article is part of a mini-series that helps readers set up everything they need to start using WSL2 for artificial intelligence, machine learning, deep learning, and or data science. It includes articles that contain instructions with copy and paste code and screenshots that help readers get the outcome as soon as possible. It also includes articles that contain instructions with explanations and screenshots that help readers process what’s happening.

01. Install Windows Subsystem for Linux 2 (WSL2)
02. Install the NVIDIA CUDA Driver and Toolkit in WSL2
03. Install Software From Source Code in WSL2
04. Install the Jupyter Notebook Home and Public Server in WSL2
05. Install Virtual Environments in Jupyter Notebook in WSL2
06. Install Programs With a Graphical User Interface in WSL2
07. Install Ubuntu Desktop With a Graphical User Interface in WSL2

--

--

David Littlefield
David Littlefield

Written by David Littlefield

From: Non-Technical | To: Technical Founder | Writes: To Make It Easier For Everyone | Topics: #Startups #How-To #Coding #AI #Machine Learning #Deep Learning

Responses (2)