- 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+o
and thenctrl+x
to save and exit the script. - Go to Windows start menu and type
Task Scheduler
to 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 on
is selected as shown below. - Then click on Triggers tab and create a New Trigger by selecting Begin the Task
At log on
from the dropdown menu and under settingsany user
and selectEnabled
under Advanced Settings. - Then go to Actions Tab and create a New Action as
Start a Program
and under Settings set Program/Script asC:\Windows\System32\bash.exe
and 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?