It is clear that it is quite tricky to get WSL to start at boot time, and that there are a variety of methods that have been used to achieve this goal.
A (Dec 24 2022) answer to a recent post here notes that Microsoft broke it when WSL moved to their store. WSL can no longer run as a service or a scheduled task because it will no longer run in session 0. superuser question on running wsl on windows boot. Then a second answer by @andrus states that one method that does work (as of Dec 25 2022) is to use set object = createobject("wscript.shell") object.run "wsl.exe", 0 still works with latest WSL and Windows 11.
Presumably that code is to be used as a vbs script, and it is to be started from the task scheduler along the lines of this article.
I haven't been able to make it work. I can start wsl using the vbs script from the command line (powershell), but it doesn't work when started from task scheduler. In case it matters, I am running windows 11 pro, downloaded wsl from the microsoft store, installed wsl using "wsl --install Ubuntu" (to install 22.04), then configured wsl to use systemd, then added the relevant "network bridge" changes in both windows, and wsl so sshd starts and the machine gets its own IP#. All of that seems to work really well when started from the command line (using wscript or cscript). But I just can't see any evidence that wsl actually starts when the vbs script is invoked from the task scheduler. Tracing the return codes from task scheduler shows only "0" return codes.
So can anyone confirm that the statement from Andrus that the solution is still working for them when they use a modern version of WSL 2, installed via microsoft store? And perhaps point me to the best description of exactly how to set it up?
wsl --version returns
WSL version: 1.0.3.0
Kernel version: 5.15.79.1
WSLg version: 1.0.47
MSRDC version: 1.2.3575
Direct3D version: 1.606.4
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22621.1105