Run services when Windows starts?
In Bash, I can set services to boot on startup with something like this:
sudo systemctl enable application.service
However, it would be really handy if certain Bash services started when Windows started. (especially for web servers, database engines etc.)
I know the way Windows and Linux does services is quite different but as an example, it would be great if I could start Windows and know that my local MongoDB server is all fired up and ready to go.
Would love to know other peoples thoughts on this and if it's at all feasible?
Kenneth Benson commented
@WinEunuuchs2Unix, I'll try anything that works. Just dl'd so I'll take a look at it. Thanks!
There is [wabasj](https://github.com/cerebrate/wabash/blob/master/README.md):
"So, you want to keep daemons or disowned processes running under Windows Services for Linux even without a bash console open? Well, look no further, friends and users, because wabash is here to help, a simple utility which keeps the WSL session going in the background all the time. It is also capable (0.5.2 and later) of automatically starting any system services/daemons capable of being started by service(8)."
Using task scheduler, I created a startup script that runs bash.exe as follows:
C:\Windows\System32\bash.exe -b /home/MYUSERNAME/wslutil/start_svcs
Where start_svcs is a su-enabled (via sudoers) script that launches openssh after
logging in to Windows. As long as I'm logged in, I can ssh into WSL from anywhere.
One thing that I can't do is to start WSL when windows boots. It's at this point that I realized
that WSL is a hobbled Linux, because it's implemented on top of Windows. It's just a shade
better than Cygwin, because WSL is implemented at a lower level.
You could try running bash.exe as a service with nssm.exe. I tried, it seems it works.
Carlos Gonzales commented
My laptop is used primarily for development and I prefer running certain services in ubuntu. I would appreciate this capability.