VB shell执行程序,直到执行完毕

shell执行程序,直到执行完毕为止:

MOD代码

Option Explicit

'# use to shell process #
Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
'# use to shell process #

Public Sub ShellAndWait(ByVal strProg As String, ByVal lStyle As VbAppWinStyle)
    Dim ProcessId As Long
    Dim ProcessHandle As Long
    Const Access As Long = &H100000
    ProcessId = Shell(strProg, lStyle)
    Do
        ProcessHandle = OpenProcess(Access, False, ProcessId)
        If ProcessHandle <> 0 Then
            CloseHandle ProcessHandle
        End If
        DoEvents
    Loop Until ProcessHandle = 0
End Sub

摘自:网络整理

相关参考


Wscript.Shell 对象详细介绍(编写.VBS

更多精彩>>>

你可能感兴趣的:(VB shell执行程序,直到执行完毕)