Results 1 to 2 of 2

Thread: Shell Command

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2000
    Posts
    32
    I am using a method found on this site to call a shell command and know when it is done executing. I got this to work just fine. My problem is that the shell window is visible. I tried to set the wShowWindow variable to 0 and 1, but had no luck.

    I was able to do this with the regular shell command, but I also need to know when it is done executing.

    Thanks in advance

    Article:
    http://www.vb-world.net/tips/tip5.html

  2. #2
    Guest
    I believe this is what you want, use like a regular Shell function which will let you know when it has been unloaded. (Text in bold is where you change it to hidden: vbHide)

    Code:
    Private Declare Function OpenProcess Lib "Kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
    Private Declare Function GetExitCodeProcess Lib "Kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long
    Private Declare Sub Sleep Lib "Kernel32" (ByVal dwMilliseconds As Long)
    Const STILL_ACTIVE = &H103
    Const PROCESS_QUERY_INFORMATION = &H400
    
    'JobtoDo - Program to run
    
    
    Sub Shell32Bit(ByVal JobToDo As String)
    
             Dim hProcess As Long
             Dim RetVal As Long
             'The next line launches JobToDo as icon,
    
             'captures process ID
             hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False, Shell(JobToDo, vbNormalFocus))
    
             Do
    
                 'Get the status of the process
                 GetExitCodeProcess hProcess, RetVal
    
                 'Sleep command recommended as well as DoEvents
                 DoEvents: Sleep 100
    
             'Loop while the process is active
             Loop While RetVal = STILL_ACTIVE
             Msgbox "App has been unloaded!"
    End Sub
    
    
    Usage
    
    Private Sub Command1_Click()
    Call Shell32Bit("C:\App\App.exe")
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width