Shell起動したアプリケーションの終了を待つ
- VB,VBA
-
2012-01-12
この記事は最終更新日から1年以上経過しています。
Dim oShell As Object, oExec As Object
'オブジェクト変数に参照をセットします
Set oShell = CreateObject("WScript.Shell")
Set oExec = oShell.Exec("C:\example.exe")
'処理完了を待機
Do Until oExec.Status: DoEvents: Loop
'戻り値をセット
If Not oExec.StdErr.AtEndOfStream Then
ExecCommand = True
sResult = oExec.StdErr.ReadAll
ElseIf Not oExec.StdOut.AtEndOfStream Then
sResult = oExec.StdOut.ReadAll
End If
'オブジェクト変数の参照を解放
Set oExec = Nothing: Set oShell = Nothing
'結果を表示
MsgBox sResult
この記事がお役に立ちましたらシェアお願いします
8,250 views




