Hi,
I have use d the code in Thread222-126053 and come up with the followig program, which has been compiled into an exe.
Public Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Public Declare Function WaitForInputIdle Lib "user32" (ByVal hProcess As Long, ByVal dwMilliseconds As Long) As Long
Public Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Public Declare Function CopyFile Lib "kernel32" Alias "CopyFileA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal bFailIfExists As Long) As Long
Private Const INFINITE = &HFFFF
Private Const SYNCHRONIZE = &H100000
Public Sub ShellAndWait(sAppPath As String, Optional iWindowStyle As VbAppWinStyle = vbMaximizedFocus, Optional lmsTimeOut As Long = INFINITE)
Dim lPid As Long
Dim hProc As Long
Dim lTimeOut As Long
lPid = Shell(sAppPath, iWindowStyle)
hProc = OpenProcess(SYNCHRONIZE, 0&, lPid)
If hProc <> 0& Then
WaitForInputIdle hProc, INFINITE
WaitForSingleObject hProc, lmsTimeOut
CloseHandle hProc
End If
End Sub
Public Sub Main()
Dim ret As Long
ShellAndWait ("D:\EBIN\Setup.exe"

Dim fso1 As FileSystemObject
Dim fil2 as File
Set fso1 = New FileSystemObject
If fso1.FileExists("C:\Desktop\SC\XYZ.mdb"

Then
Set fil2 = fso2.GetFile("E:\SC\XYZ.mdb"

fil2.Copy "C:\Desktop\SC\xyz.mdb", True
MsgBox "XYZ.mdb copied successfully"
Else
MsgBox "Error."
GoTo unloadForm
End If
unloadForm:
Set fil2 = Nothing
Set fso1 = Nothing
End Sub
The Startup form is Main. The Setup.exe that is shelled at the start requires a few user inputs like choosing the version (stand alone, network etc), agreeing to the license terms etc. After the files are copied, the user need to click on the Finish button to complete the setup.
After this the file copy needs to be carried out.
The problem is: It does not work when I just run the exe. It opens the initial Setup screen and hangs. But if I step thru the code, the program works properly.
Please help me with this problem.
Thanks in advance and sorry for the long post.
Hope it helps. Let me know what happens.
With regards,
PGK