|It's the Shell command that is the problem. It wont work in these circumstances.|
You need to run the CreateProcess API to start the process. You then use the process handle returned to pause execution via the WaitForSingleObject API. it is the only way that you are going to pause a VB application for an indeterminate period.
You could use the Sleep API but that means predefining the pause period which may be too long or two short.
Here is a snippet of code that will point yo in the right direction:
Public Function SyncShell(CommandLine As String, Optional Timeout As Long, _
Optional WaitForInputIdle As Boolean, Optional Hide As Boolean = False) As Boolean
Dim hProcess As Long
Dim ret As Long
Dim nMilliseconds As Long
If Timeout > 0 Then
nMilliseconds = Timeout
nMilliseconds = INFINITE
hProcess = StartProcess(CommandLine, Hide)
If WaitForInputIdle Then
'Wait for the shelled application to finish setting up its UI:
ret = InputIdle(hProcess, nMilliseconds)
'Wait for the shelled application to terminate:
ret = WaitForSingleObject(hProcess, nMilliseconds)
'Return True if the application finished. Otherwise it timed out or erred.
SyncShell = (ret = WAIT_OBJECT_0)
INFINITE is a constant with a value of -1
If you want to learn how to use the WaitForSingle object it is used on the Setup1.vbp application that comes with VB6. It is a good source of VB programming ideas.