WSL: Difference between revisions

imported>Onny
Add note on update WSL
imported>Onny
Run container on startup
Line 24: Line 24:
wsl -d NixOS
wsl -d NixOS
</syntaxhighlight>
</syntaxhighlight>
== Tips and tricks ==
== Run container on startup ==
To run the distro <code>NixOS</code> on Windows startup or user login in the background, proceed with following commands in PowerShell
<syntaxhighlight lang="bash">
echo "" > $HOME\run_wsl2_at_startup.vbs
notepad $HOME\run_wsl2_at_startup.vbs
</syntaxhighlight>
Inside the script we define <code>NixOS</code> as the distribution name, as imported in the setup step above
{{file|$HOME\run_wsl2_at_startup.vbs|vbs|<nowiki>
set object = createobject("wscript.shell")
object.run "wsl.exe --distribution NixOS", 0
</nowiki>}}
Execute following command to open the task planer
<syntaxhighlight lang="bash">
taskschd.msc
</syntaxhighlight>
Click on <code>New task</code> on the right pane, set name to <code>WSL</code>. On the tab "Triggers" click on "New ..." and select run task on user login. On the tab "Action" click on "New ..." and insert as command: <code>%USERPROFILE%\run_wsl2_at_startup.vbs</code>