Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Const SW_SHOWNORMAL = 1
Private Sub Command1_Click()
ShellExecute Me.hwnd, vbNullString, "notepad.exe", vbNullString, "C:\", SW_SHOWNORMAL
MsgBox "NotePad has been Opened"
End Sub
When ever I run the code listed above notepad immediately opens and then the message box appears indicating that execution of the code continued and did not wait for the program launched by the shellExecute command to close/stop.
Also, the SH_NORMAL command activates and displays the window. If you wanted to launch and forget it then you probably would want to use a different value for nShowCmd.
Here is some documentation on SH_NORMAL:
SW_SHOWNORMAL
Activates and displays a window. If the window is minimized or maximized, Windows restores it to its original size and position. An application should specify this flag when displaying the window for the first time.
According to the API viewer the value for SH_SHOWNORMAL is 1. I think you probably want to use SW_HIDE so you can forget about it. SW_HIDE const value is 0.
Here is some documentation of SW_HIDE:
SW_HIDE
Hides the window and activates another window.
again, I'm still a bit confused by this statement:
"from my experience it waits for the shelled app to finish before going on"