win11中vbs的文件关联被去掉了,vbs文件不能双击执行,开机启动一个不显示窗口的任务无法完成;
解决办法:控制页面-》系统和安全-》计划任务--》执行命令
比如我们需要开机自启动wsl中的某个服务:
Set ws = WScript.CreateObject("WScript.Shell")
ws.run "wsl -u root /etc/init.wsl"
替换到powershell中的效果为:
# 运行程序:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
# 命令参数
-Command {Start-Process -FilePath "C:\Windows\System32\wsl.exe" -ArgumentList "-u root /etc/init.wsl" -WindowStyle Hidden}
附录
如何查看powershell的具体用法?Win+R,cmd,powershell /?
如何查看powershell的具体文件位置?Win+R,cmd,where powershell