当前位置:编程学习 > VB >>

调用程序并等待程序返回运行结果

'========================================================================= 
'创建日期: 2011-06-01,hellostory 
'函数说明: 运行并等待程序执行完毕,同时返回程序运行结果 
'参数说明: strCommand  - 需要被执行的命令或程序 
'返回值:   被执行的命令或程序自身返回的运行结果 
'========================================================================= 
Public Function runAndWaitExe(strCommand As String) As Integer 
On Error GoTo errHandler 
Dim WshShell As Object 
Set WshShell = CreateObject("wscript.shell") 
runAndWaitExe = WshShell.Run(strCommand, 0, True) 
 
errHandler: 
    If Err.Number Then  www.zzzyk.com
        MsgBox "执行命令( " & strCommand & " )时发生错误:" & Err.Description, vbCritical, "错误" 
        Debug.Print strCommand 
        Resume Next 
    End If 
End Function 

摘自 hellostory的专栏
补充:软件开发 , Vb ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,