- First open a script using nano in your WSL terminal by running this command:
sudo nano ~/.local/bin/start_script
- Copy the following command in that scipt:
service mysql start
service mongodb start
- Press
ctrl+oand thenctrl+xto save and exit the script. - Go to Windows start menu and type
Task Schedulerto open Task Scheduler. - Under the Actions tab on the right hand side, click
Create Task...to open create task window - On this window give your task a specific name and make sure
Run only when user is logged onis selected as shown below. - Then click on Triggers tab and create a New Trigger by selecting Begin the Task
At log onfrom the dropdown menu and under settingsany userand selectEnabledunder Advanced Settings. - Then go to Actions Tab and create a New Action as
Start a Programand under Settings set Program/Script asC:\Windows\System32\bash.exeand in the Add arguments-c "sudo ~/.local/bin/start_services.sh"as shown below.
That's all. The next time Windows starts, task will be triggered and it will run your custom script as root and start mongodb and mysql. You can also add any other services to this script.
Top comments (1)
Have you tried this yourself?