Support for starting the Linux services in Windows Subsystem for Linux (WSL) on Windows startup
Branch: master
Clone or download
Latest commit bb7b630 Oct 30, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
doc Added doc photos Jul 16, 2018
LICENSE Initial commit Jul 15, 2018
README.md Update README.md Oct 29, 2018
README_zh.md Add readme files Jul 16, 2018
commands.txt first commit Jul 15, 2018
control.bat support automatically check & get admin rights Aug 6, 2018
start.vbs support automatically check & get admin rights Aug 6, 2018
stop.vbs support automatically check & get admin rights Aug 6, 2018

README.md

WSL Autostart

Support for starting the Linux services in Windows Subsystem for Linux (WSL) on Windows startup.

README | 中文文档

Table of Contents

Installation

  • Clone to any directory using the git command: (e.g C:\wsl-autostart)
git clone https://github.com/troytse/wsl-autostart
  • Add a startup item to the registry. run-regedit

  • Add a string item under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run (e.g WSLAutostart) regedit-new-item

  • Set the path to the script (e.g C:\wsl-autostart\start.vbs) regedit-set-path

Usage

  • Modify /etc/sudoers file in the WSL to specify the service commands calling on startup without a password. e.g:
%sudo ALL=NOPASSWD: /etc/init.d/cron
%sudo ALL=NOPASSWD: /etc/init.d/ssh
%sudo ALL=NOPASSWD: /etc/init.d/mysql
%sudo ALL=NOPASSWD: /etc/init.d/apache2
  • Modify commands.txt file to specify the service commands for your need. e.g:
/etc/init.d/cron
/etc/init.d/ssh
/etc/init.d/mysql
/etc/init.d/apache2

Other methods

  • Using gpedit.msc, it is possible to define a program that runs when the computer starts

    Note that the configured program will run as the system user.

  • Using taskschd.msc, it is possible to schedule a task after the startup of the computer.

    You may configure which user will run the program, a delay before a run and a number of retries. the same taskschd.msc program will show a specific log regarding the execution of the task