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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AUTORUN . . how to lauch a setup.exe from VB app

Status
Not open for further replies.

MikeMCSD

MIS
Jul 12, 2002
107
0
0
US
Hello,
I made an AUTORUN.INF file:
[autorun]
OPEN=start.exe

When the program appears after it is loaded in the
CD Drive, the user has 4 choices to choose from,
4 command buttons.
The 4 programs are *.exe programs. One of them is a
setup.exe program.

I get an error "Run-time error'53': File not found.
This is the code I used to try to launch the setup.exe:

Private Sub Command1_Click()
Call Shell(App.Path + "\setup.exe", 1)
End Sub

I can't give the path of the CD Drive because it could
be any letter. I figured App.Path would do the trick.

Any help would be greatly appreciated. Thanks
 
With a little detective work, I figured out
what the problem was.
I just had to make one small change to the
above code.
Can anybody see what the problem was???
 
[autorun]
OPEN=start.exe <-- from this am assuming that your program is in the root folder (e.g., &quot;D:\&quot;)

Private Sub Command1_Click()
Call Shell(App.Path + &quot;\setup.exe&quot;, 1) <-- App.Path + &quot;\setup.exe&quot; = &quot;D:\\setup.exe&quot;
End Sub

 
EZ, I couldn't use a hard-coded drive letter for the
CD drive because this program should be able to work
on anybody's machine, and not everyone's CD drive is going
to be D:\ (mine is actually G:\)

I just made one small change to the following code
and it worked:

Private Sub Command1_Click()
Call Shell(App.Path + &quot;\setup.exe&quot;, 1)
End Sub

anyone game to figure out what I did???
 
I might be wrong, but thats a problem I have to sort out for myself. I have used a similar App.Path & &quot;\setup.exe&quot; but it will bounce unles I am correct. For if the application path is C:\Directory then adding \setup.exe will work, however if the user selects C:\ then adding another \ will make it fall over. Am I right somebody or wrong. Sorry to pounce on your question but I needed to know for myself. Regards
 
yes you are right . . when the CD is put in the drive,
App.Path evaluates to the CD letter of the drive,
e.g. D:\ G:\ or whatever letter was assigned to it.
having the extra &quot;\&quot; gave the file not found error.

I changed:
Call Shell(App.Path + &quot;\setup.exe&quot;, 1)
to
Call Shell(App.Path + &quot;setup.exe&quot;, 1)

and it worked.
Oh, and EZ, I didn't see what you did at first
(the red &quot;\&quot;) and you were right too.
 
As a quick work-around, I frequently use code like the following to ensure I have a valid path (Note: make sure you start with byte 2 if using UNC otherwise you'll break your code):

strPath = Replace$(App.Path & &quot;\setup.exe&quot;, &quot;\\&quot; &quot;\&quot;)
 
I aactually posted about this some hours ago... I have the same problem but the weird thing is that before I reinstalled my XP, my app's shell worked fine (even when the path came out like "k:\\list.m3u"). In fact since the code worked perfectly I currently have over 200 cds with the app burned on them, and now they just throw error 53 on my machine. What dll does the shell come from? I guess I was using a diferent dll version before, but I don't have a clue about its name.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top