- VB,VBA
-
2012-01-12
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,261 views




