我想更新从 VBA shell 或 WScript.Shell 命令调用的命令提示符并启动 wsl.exe。这是因为 wsl.exe 不包含在 shell 或 WScript.Shell 调用的命令提示符中。
Sub Sample1()
Dim WSH, wExec, sCmd, Result As String
Set WSH = CreateObject("WScript.Shell")
sCmd = "dir c:\Windows\System32\ws*.exe"
Set wExec = WSH.Exec("%ComSpec% /c " & sCmd)
Do While wExec.Status = 0
DoEvents
Loop
Result = wExec.StdOut.ReadAll
MsgBox Result
Set wExec = Nothing
Set WSH = Nothing
End Sub