Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Execute exe directly from CD

Status
Not open for further replies.

pgk

Programmer
Jul 19, 2002
262
0
0
US
Hi,
I donot know if this is the right forum to postthis question but still I am sure someone here will know the answer. Now for the question:

Is it possible to run an exe directly from the CD? I have got an exe on a CD which will copy a couple of files to the local disk. The files are also on the CD. If a user double clicks this exe or types X:\CopySetup.exe, will it execute properly?

Also I have used App.Path + "\File1.dat" in the copy command. Will this work properly?


Thanks in advance. Hope it helps. Let me know what happens.
With regards,
PGK
 
what do you want to do?
Here is what i understand.
when the user tries to run the exe from his hard drive, you want to pass the control to the exe which is there on the CD.
In this case, while installing, make entries in registry to remember drive letter for the cdrom, then call this exe like:
Dim CDDrive
CDDrive = <getentriesfromregistry>

shell CDDrive & &quot;/yourEXE.exe&quot;
 

Take a look at the setup project that came with vb. Using that as a template you may be able to accomplish what you want.

Good Luck

 

You will need to make sure the VB runtime files, and any OCX's needed are on the machine running the program and are registered.

One way to do this is to have a set-up program for just those runtime files.

You could also use a VB3 program....
[/b][/i][/u][sub]*******************************************************
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!
 
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 + &quot;\Setup.exe&quot;,True

When this is finished, run the follwoing File COpy commands:

fso.FileCopy &quot;XYZ.dat&quot;,&quot;XYZ.dat&quot;,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 = &quot;&quot;
drvLetter = InputBox(&quot;Please enter the letter of your CD Drive. If it is E:, enter E&quot;, &quot;Enter Drive Letter&quot;)
If drvLetter = &quot;&quot; Then
MsgBox &quot;You have chosen to exit the setup program. You can install it at a later time.&quot;, vbInformation, &quot;Setup aborted&quot;
Exit Sub
End If
If Len(drvLetter) > 1 Then
MsgBox &quot;Please enter only the letter representing your CD drive. If it is E:, enter E&quot;, vbExclamation, &quot;Invalid Input&quot;
GoTo getDrvLetter
End If
If (Asc(drvLetter) < 64 Or Asc(drvLetter) > 90) And (Asc(drvLetter) < 95 Or Asc(drvLetter) > 121) Then
MsgBox &quot;Please enter a valid alphabet that represents your CD drive.&quot;, vbExclamation, &quot;Invalid Input&quot;
GoTo getDrvLetter
End If
'Dim oWiSh As Object
'Set oWiSh = CreateObject(&quot;WScript.Shell&quot;)
'iReturn = oWiSh.run(drvLetter + &quot;:\Setup.exe&quot;, 1, True)
'Set oWiSh = Nothing
Set fso1 = New FileSystemObject
If fso1.FileExists(&quot;C:\pgk\parts.mdb&quot;) Then
fso1.CopyFile drvLetter + &quot;:\parts.mdb&quot;, &quot;C:\pgk\parts.mdb&quot;, True
Set fil1 = fso1.GetFile(&quot;C:\pgk\parts.mdb&quot;)
fil1.Attributes = Archive
Set fil1 = Nothing
'MsgBox &quot;File Copied Successfully&quot;
End If
closeAll:
Set fso1 = Nothing
MsgBox &quot;Setup is now complete.&quot;, vbInformation, &quot;Setup Complete&quot;
Exit Sub
errHandler:
Select Case Err.Number
Case 53
MsgBox &quot;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.&quot;, vbExclamation, &quot;Error&quot;
Exit Sub
Case Else
MsgBox &quot;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.&quot;, vbExclamation, &quot;Error&quot;
Exit Sub
End Select
End Sub

Watch out for word wraps. Hope it helps. Let me know what happens.
With regards,
PGK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top