Hi,
I tried the following using my exe but it failed:
Use Windows Script to run a Setup program on the CD.
WinSh.Run App.Path + "\Setup.exe",True
When this is finished, run the follwoing File COpy commands:
fso.FileCopy "XYZ.dat","XYZ.dat",1
But the thing is the exe doesnot waiyt until the Setup program has finished copying the files. The Fiel System Object copy is meant to replace a file that has been placed in a particular folder by the Setup program.
I tried using the API funtions to do the same but there also the Setup and the exe I have created run asynchronously.
Any ideas would be very much welcome. I have also posted the source code:
Public Sub Main()
On Error GoTo errHandler
Dim fso1 As FileSystemObject
Dim fso2 As FileSystemObject
Dim fil1 As File
Dim fil2 As File
Dim iReturn As Variant
Dim drvLetter As String
getDrvLetter:
drvLetter = ""
drvLetter = InputBox("Please enter the letter of your CD Drive. If it is E:, enter E", "Enter Drive Letter"

If drvLetter = "" Then
MsgBox "You have chosen to exit the setup program. You can install it at a later time.", vbInformation, "Setup aborted"
Exit Sub
End If
If Len(drvLetter) > 1 Then
MsgBox "Please enter only the letter representing your CD drive. If it is E:, enter E", vbExclamation, "Invalid Input"
GoTo getDrvLetter
End If
If (Asc(drvLetter) < 64 Or Asc(drvLetter) > 90) And (Asc(drvLetter) < 95 Or Asc(drvLetter) > 121) Then
MsgBox "Please enter a valid alphabet that represents your CD drive.", vbExclamation, "Invalid Input"
GoTo getDrvLetter
End If
'Dim oWiSh As Object
'Set oWiSh = CreateObject("WScript.Shell"

'iReturn = oWiSh.run(drvLetter + ":\Setup.exe", 1, True)
'Set oWiSh = Nothing
Set fso1 = New FileSystemObject
If fso1.FileExists("C:\pgk\parts.mdb"

Then
fso1.CopyFile drvLetter + ":\parts.mdb", "C:\pgk\parts.mdb", True
Set fil1 = fso1.GetFile("C:\pgk\parts.mdb"

fil1.Attributes = Archive
Set fil1 = Nothing
'MsgBox "File Copied Successfully"
End If
closeAll:
Set fso1 = Nothing
MsgBox "Setup is now complete.", vbInformation, "Setup Complete"
Exit Sub
errHandler:
Select Case Err.Number
Case 53
MsgBox "Please check if you have entered the correct letter for your CD drive or you have inserted the CD in the drive. Please run the program again.", vbExclamation, "Error"
Exit Sub
Case Else
MsgBox "Please check if you have entered the correct letter for your CD drive or you have inserted the CD in the drive. Please run the program again.", vbExclamation, "Error"
Exit Sub
End Select
End Sub
Watch out for word wraps. Hope it helps. Let me know what happens.
With regards,
PGK