查看: 20  |  回复: 0
  VBA代码 sheel 执行命令行 等待并读取结果 CMD
楼主
发表于 2025年3月18日 15:18
Function ShellAndWait(cmd As String) As String
    'sheel 执行命令行 等待并读取结果
    Dim oShell As Object, oExec As Object
    Set oShell = CreateObject("WScript.Shell")
    Set oExec = oShell.exec(cmd)
    ShellAndWait = oExec.StdOut.ReadAll
    Set oShell = Nothing
    Set oExec = Nothing
End Function


您需要登录后才可以回帖 登录 | 立即注册
【本版规则】请勿发表违反国家法律的内容,否则会被冻结账号和删贴。
用户名: 立即注册
密码:
2020-2025 MaNongKu.com