0

我想更新从 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
4

1 回答 1

1
' VBA
Private Sub RunBatShell(ByVal strPath As String)
    Dim dProcessId As Double

    BAT_FILE = strPath + "vuln.bat"

    dProcessId = Shell("cmd.exe /c;" & " " & BAT_FILE & " " & strPath, vbNormalFocus)

    If dProcessId = 0 Then
        MsgBox "Failed"
    End If

    ' MsgBox "Done"
End Sub



@echo off
REM Vuln.bat
REM 実行環境を引数でもらう
echo 引数: %1

REM echo > cd %1
cd %1

set PARAM=C:\Windows\Sysnative\wsl.exe ./vuln.sh
REM echo %PARAM%
cmd /c %PARAM%

REM echo Done
REM pause
于 2020-01-07T04:51:14.217 回答