Bash on Ubuntu on Windows 启动后会自动在后台运行

Will Bash on Ubuntu on Windows automatically run in background after starting up

在“打开或关闭 Windows 功能”中,如果“Windows 子系统 Linux( Beta)”勾选后,Windows开机后子系统会自动运行,还是只有运行用户打开bash.exe?

安装文档 (https://msdn.microsoft.com/en-us/commandline/wsl/install_guide) 说 "to launch Bash on Windows, either run bash at a cmd/PowerShell command-prompt, or use the start menu shortcut"。

我觉得Windows启动时不会自动启动,除非你修改一些Windows配置。

编辑:您可以在启动时创建任何程序 运行,方法是转到 "Run",输入 "shell:common startup" 并在该文件夹中添加该程序的快捷方式。

这是两年前的问题。我在 Windows 10 1903.

上为 Ubuntu 18.04 提供了一个巧妙的解决方案

按 Win+R 和 运行:

shell:startup

创建一个脚本 ubuntu.vbs,内容为:

Set ws = CreateObject("Wscript.Shell")
ws.run "wsl -d ubuntu -u root /etc/init.d/ssh start", vbhide

这是在 Windows 启动时在后台启动 ssh 的巧妙解决方案。

参考:Zhihu