By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,369 Members | 1,207 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,369 IT Pros & Developers. It's quick & easy.

Auto-boot vb program from cd

P: n/a
Hi

I'm wanting to create a cd-rom which boots automatically when it's inserted
into the computer. What I hope to achieve is for a VB6 program to run
automatically when the cd boots up. Can this be done? if yes, then how?
Also, how do I link a command button click to the opening of files within
the cd, i.e. word, excel and access files?

Thanks
Jul 17 '05 #1
Share this Question
Share on Google+
21 Replies


P: n/a
"Roy Riddex" <ro**************@blueyonder.co.uk> wrote:
Hi

I'm wanting to create a cd-rom which boots automatically when it's inserted
into the computer. What I hope to achieve is for a VB6 program to run
automatically when the cd boots up. Can this be done? if yes, then how?
Also, how do I link a command button click to the opening of files within
the cd, i.e. word, excel and access files?

Thanks


The term is autorun, not autoboot - which is a totally different animal.
Autorun requires that the CD device be set for autorun/play and that the CD have
and autorun.ini file that specifies what program is to be run.

The "gotcha's" with VB is that you'll have to include the run time file and, if
you use any ocx's, you'll have to register them on the target PC.

More about me: http://www.jecarter.com/
VB3/VB6/NSBasic Palm/C/PowerBasic source code: http://www.jecarter.com/programs.html
Drivers for Pablo graphics tablet and JamCam cameras: http://home.earthlink.net/~mwbt/
johnecarter at@at mindspring dot.dot com. Fix the obvious to reply by email.
Jul 17 '05 #2

P: n/a

"the Wiz" <lo**@message.body> wrote in message
news:97********************************@4ax.com...
"Roy Riddex" <ro**************@blueyonder.co.uk> wrote:
Hi

I'm wanting to create a cd-rom which boots automatically when it's insertedinto the computer. What I hope to achieve is for a VB6 program to run
automatically when the cd boots up. Can this be done? if yes, then how?
Also, how do I link a command button click to the opening of files within
the cd, i.e. word, excel and access files?

Thanks

The term is autorun, not autoboot - which is a totally different animal.
Autorun requires that the CD device be set for autorun/play and that the

CD have and autorun.ini file that specifies what program is to be run.

The "gotcha's" with VB is that you'll have to include the run time file and, if you use any ocx's, you'll have to register them on the target PC.

I'm sorry but I'm a newbie and most of what you just said doesn't mean
anything to me. You've said what needs to be done without telling me how to
do it. I don't know what a run time file?? ocx's?? register them on target
pc?? what do you mean?
Jul 17 '05 #3

P: n/a
> > >I'm wanting to create a cd-rom which boots automatically when it's
inserted
into the computer. What I hope to achieve is for a VB6 program to run
automatically when the cd boots up. Can this be done? if yes, then how?
Also, how do I link a command button click to the opening of files withinthe cd, i.e. word, excel and access files?

The term is Autorun. It means to run a program from a CD when it is inserted
into a Windows-based computer. This feature only works on Windows 95
upwards.

The way you do it is by putting the program on the CD as you normally would.
This program needs a file to run, which may or may not be present on the
computer you Autorun it on. However, this can be worked around by putting
the "Run-time files" on the CD, in the same folder as the program
(hopefully, not in a folder, but on the disc). For Visual Basic 4 programs,
it MSVB4032.DLL, for Visual Basic 5 it MSVBVM50.DLL and Visual Basic 6 its
MSVBVM60.DLL, any of which should be in your Windows folder on your
hard-drive (typically C:\Windows or C:\Winnt - do a search if you don't
know).
Any extra features (controls) your program uses needs extra files which
complicate things, so make it simple!
Finally, this CD is useless without one final file, called "AUTORUN.INF".
This file tells Windows how it should Autorun the CD. It should contain the
following lines:
[autorun]
open = program.exe
icon = iconfile.ico
The icon line doesn't have to be there. It's if you have a specific icon for
the CD. Also, program.exe should be the name of your program on the disc,
including any folders it's in on the CD. (eg "myapp.exe",
"program\myapp.exe", etc)

Once you have these files ready, burn the Autorun.inf file to the root of
the CD (ie, not in any folder) and the program file and "run-time files" in
the same folder, which is the folder written in Autorun.inf.

Hope this now makes sense. It's easier as you get used to doing it.

--
QuickHare
Remove the NOT HERE to email direct.
Jul 17 '05 #4

P: n/a
"Roy Riddex" <ro**************@blueyonder.co.uk> wrote:

"the Wiz" <lo**@message.body> wrote in message
news:97********************************@4ax.com.. .
"Roy Riddex" <ro**************@blueyonder.co.uk> wrote:
>Hi
>
>I'm wanting to create a cd-rom which boots automatically when it'sinserted >into the computer. What I hope to achieve is for a VB6 program to run
>automatically when the cd boots up. Can this be done? if yes, then how?
>Also, how do I link a command button click to the opening of files within
>the cd, i.e. word, excel and access files?
>
>Thanks
>


The term is autorun, not autoboot - which is a totally different animal.
Autorun requires that the CD device be set for autorun/play and that the

CD have
and autorun.ini file that specifies what program is to be run.

The "gotcha's" with VB is that you'll have to include the run time file

and, if
you use any ocx's, you'll have to register them on the target PC.

I'm sorry but I'm a newbie and most of what you just said doesn't mean
anything to me. You've said what needs to be done without telling me how to
do it. I don't know what a run time file?? ocx's?? register them on target
pc?? what do you mean?


I think you just admitted to never reading any of the VB documentation ;-)

VB does not create stand-alone executable programs. They require the VB run
time file for support (this a .dll file that contains the code that supports the
most common VB controls).

VB also uses add-in controls (ocx files) such as the common dialog control. If
you use this control in your program, you must include it in the distribution
files.

The OCX files must be registered with Windows so it can find them when they are
referenced by a VB program. This is usually done with the regsvr32 program.

If this is all still Greek to you, you need to get a good book on VB6
programming. The "Integrated Project" course at the university used this one:
Visual Basic 6 Programming
Author: Jeffrey J. Tsay
ISBN: 0-13-026199-8
amazon.com has it for $69.33
http://www.amazon.com/exec/obidos/AS...502002-5712611
More about me: http://www.jecarter.com/
VB3/VB6/NSBasic Palm/C/PowerBasic source code: http://www.jecarter.com/programs.html
Drivers for Pablo graphics tablet and JamCam cameras: http://home.earthlink.net/~mwbt/
johnecarter at@at mindspring dot.dot com. Fix the obvious to reply by email.
Jul 17 '05 #5

P: n/a
>I think you just admitted to never reading any of the VB documentation ;-)

lol, my version of VB6 was supplied by my college. It's on a student
license, but the help library is on a different license which my college is
unable to distribute. So when I'm programming at home all I have for
reference is a beginners guide to VB6.
VB does not create stand-alone executable programs


I haven't tried it yet but what happens when you select the option 'Make
project.exe'?
One last question. If I manage to complete the CD, will it be a stand alone
cd that should run on any pc whether it has VB installed or not?


Jul 17 '05 #6

P: n/a
On Thu, 13 Nov 2003 10:20:23 -0000, "Roy Riddex"
<ro**************@blueyonder.co.uk> wrote:
I think you just admitted to never reading any of the VB documentation ;-)
lol, my version of VB6 was supplied by my college. It's on a student
license, but the help library is on a different license which my college is
unable to distribute. So when I'm programming at home all I have for
reference is a beginners guide to VB6.

You really do need the Help Files
- even if it means being devious
- without them you are crippled
- it amazes me that MS expect 'Academics' to work without them
VB does not create stand-alone executable programs
I haven't tried it yet but what happens when you select the option 'Make
project.exe'?

It should make an EXE
That EXE *MUST* have MSVBVM60.DLL on the machine it runs on
- ie: stick that on the CD with your EXEOne last question. If I manage to complete the CD, will it be a stand alone
cd that should run on any pc whether it has VB installed or not?
If you do not use any OCXes whatsoever, then provided the EXE can find
MSVBVM60.DLL the EXE is to all intents and purposes 'standalone'

However, since you are very new to VB, you have probably used all
sorts of interesting (and totally unnecessary) 'additional' controls.

You can find out by using Notepad on your project's .VBP file
(back it up first)

If you *have* to distribute OCXes, then you need to produce an Install
Pack
- eg: a Setup system for your App

Which is a PITA - and probably defeats the purpose of your system

However, with a little care you *can* produce a 'standalone' CD that
requires no installation, and runs cleanly from AutoRun.inf when the
CD is inserted

I know, I've been sending out just such a system for years

HTH

BTW, Rick Rothstein posted this link for VB Help/Reference online

Watch for wrapping:

http://msdn.microsoft.com/library/de...LROverview.asp

Here it is as a TinyUrl :-

http://tinyurl.com/uu0u


Jul 17 '05 #7

P: n/a
If you do not use any OCXes whatsoever, then provided the EXE can find
MSVBVM60.DLL the EXE is to all intents and purposes 'standalone'

However, since you are very new to VB, you have probably used all
sorts of interesting (and totally unnecessary) 'additional' controls.

I'm still a little unsure about ocx's. All my program does is provide links
to other files on the CD via several command buttons on one form. Is this
basic enough to work as a stand alone?
Jul 17 '05 #8

P: n/a
On Thu, 13 Nov 2003 22:41:45 -0000, "Roy Riddex"
<ro**************@blueyonder.co.uk> wrote:
If you do not use any OCXes whatsoever, then provided the EXE can find
MSVBVM60.DLL the EXE is to all intents and purposes 'standalone'

However, since you are very new to VB, you have probably used all
sorts of interesting (and totally unnecessary) 'additional' controls.

I'm still a little unsure about ocx's. All my program does is provide links
to other files on the CD via several command buttons on one form. Is this
basic enough to work as a stand alone?


If you are just using the 'basic' controls, then yes, that will be Ok

However, to save you agony, I suggest that you post your .VBP file
here, and we'll look over it

- when I first started with VB I added all sorts of things to the
project, to see what they did, and even though unused, they stayed
there. There are ways of removing them, but the safest thing is to
look at the references in the .VBP
Jul 17 '05 #9

P: n/a
> If you are just using the 'basic' controls, then yes, that will be Ok

However, to save you agony, I suggest that you post your .VBP file
here, and we'll look over it

- when I first started with VB I added all sorts of things to the
project, to see what they did, and even though unused, they stayed
there. There are ways of removing them, but the safest thing is to
look at the references in the .VBP

Thanks for the advice. My program isn't finished yet because the command
buttons aren't aimed at anything just yet. Only after I finalise the other
files to be on the disk can I finish off my VB program. It wont be for a few
weeks but if I have any probs I'll post the program for you to have a look
at.
Thanks again.
Jul 17 '05 #10

P: n/a
On Fri, 14 Nov 2003 16:26:15 -0000, "Roy Riddex"
<ro**************@blueyonder.co.uk> wrote:
If you are just using the 'basic' controls, then yes, that will be Ok

However, to save you agony, I suggest that you post your .VBP file
here, and we'll look over it

- when I first started with VB I added all sorts of things to the
project, to see what they did, and even though unused, they stayed
there. There are ways of removing them, but the safest thing is to
look at the references in the .VBP

Thanks for the advice. My program isn't finished yet because the command
buttons aren't aimed at anything just yet. Only after I finalise the other
files to be on the disk can I finish off my VB program. It wont be for a few
weeks but if I have any probs I'll post the program for you to have a look
at.
Thanks again.


No Problem
Jul 17 '05 #11

P: n/a
Grrr. I've been trying to use my VB book to learn how to open files but
still I have problems....
Here's my code for opening files through VB6:

Option Explicit
Dim Helpfile As String

Private Sub Form_Load()
Helpfile = App.Path & "\HelpFile.doc"
End Sub

Private Sub cmdHelp_Click()
Open Helpfile For Append As #1
End Sub

I've also tried typing out the complete path in the form load event but
still wont work. I hit the command button once but nothing happens so I hit
it again and I get a message saying the file is already open. I don't want
VB to do anything with the file or the data within the file, only to open it
(which I assume will then open MS Word in turn). To be honest, I aint sure
what 'Append as #1' does because the book doesn't make much sense to me.
It's probably a simple thing but omg it's really starting to annoy me, any
help would be greatly appreciated.
Jul 17 '05 #12

P: n/a


Roy Riddex wrote:
Grrr. I've been trying to use my VB book to learn how to open files but
still I have problems....
Here's my code for opening files through VB6:

Option Explicit
Dim Helpfile As String

Private Sub Form_Load()
Helpfile = App.Path & "\HelpFile.doc"
End Sub

Private Sub cmdHelp_Click()
Open Helpfile For Append As #1
End Sub


Your open statement opens a file for output, not input. Any write
commands will add to the end (append) to an existing file or create a
new file if it doesn't already exist.

There are many ways to open a word document. One way is to use
shellexecute.

A better way is to use VB6's word reference. Within the VB6 editor
enable a reference to the word libary. Once thats done one way to open
a document would be as follows:

Dim ObJWod as Word.Application
Set ObjWord = New Word.Application
ObjWord.Documents.Open (strFilename)

Word is probably not the best way to make a help file though. Since it
displays an entire document as is not context sensitive. I use the
older windows .hlp files. You'll need a help editor and microsofts help
compiler (free) though. Current methods use html help files but I do
not like them. Much slower than the older .hlp files. Either way that
would make them context sensitive, able to index, search etc.
Jul 17 '05 #13

P: n/a
On Sun, 16 Nov 2003 23:47:38 -0000, "Roy Riddex"
<ro**************@blueyonder.co.uk> wrote:
Grrr. I've been trying to use my VB book to learn how to open files but
still I have problems....
Here's my code for opening files through VB6:

Option Explicit
Dim Helpfile As String

Private Sub Form_Load()
Helpfile = App.Path & "\HelpFile.doc"
End Sub

Private Sub cmdHelp_Click()
Open Helpfile For Append As #1
End Sub


Miles is quite right about the Append stuff

The real question is, however, *exactly* what you want to do

My guess is read the file into a Textbox in order to display it
- however I could be wrong

Jul 17 '05 #14

P: n/a
>>A better way is to use VB6's word reference. Within the VB6 editor
enable a reference to the word libary"

I haven't used this feature before, what is the VB6 editor?
Word is probably not the best way to make a help file though. Since it
displays an entire document as is not context sensitive. I use the
older windows .hlp files. You'll need a help editor and microsofts help
compiler (free) though. Current methods use html help files but I do
not like them. Much slower than the older .hlp files. Either way that
would make them context sensitive, able to index, search etc.
Thanks for the advice about help files. My word document is 2 pages max for
a small college project so I'll stick with using MS Word as the whole thing
seems to be getting more and more complicated.
The real question is, however, *exactly* what you want to do
My guess is read the file into a Textbox in order to display it
- however I could be wrong


As I said, I don't want VB to do anything with the file other than to act as
a shortcut to the file.
Here goes, I have a simple form which I hope to autorun when a cd is
inserted into the drive. All I want the form to do is provide links (via
command buttons) to allow a user to view the files. I need to be able to
provide links to word, access, excel and powerpoint files. I am completely
new to VB6 (aint programmed for over 10 years since school on bbc micro) and
I assumed having links to other files would be easy but so far it's been a
nightmare.
Can someone please tell me in simple terms how to link the pressing of a
command button to the opening of word and the opening of a document, or the
opening of powerpoint and the opening of a powerpoint file etc....

Jul 17 '05 #15

P: n/a
On Mon, 17 Nov 2003 19:33:54 -0000, "Roy Riddex"
<ro**************@blueyonder.co.uk> wrote:

<snip>
As I said, I don't want VB to do anything with the file other than to act as
a shortcut to the file.
Here goes, I have a simple form which I hope to autorun when a cd is
inserted into the drive. All I want the form to do is provide links (via
command buttons) to allow a user to view the files. I need to be able to
provide links to word, access, excel and powerpoint files. I am completely
new to VB6 (aint programmed for over 10 years since school on bbc micro) and
I assumed having links to other files would be easy but so far it's been a
nightmare.
Can someone please tell me in simple terms how to link the pressing of a
command button to the opening of word and the opening of a document, or the
opening of powerpoint and the opening of a powerpoint file etc....


1. Goto www.AllAPI.net
2. Download their API Guide
3. Look inside it for ShellExecute

HTH
Jul 17 '05 #16

P: n/a

1. Goto www.AllAPI.net
2. Download their API Guide
3. Look inside it for ShellExecute


Downloaded the API guide. Their example opens an email. Since I haven't
learned anything as advanced as shellexecute in college yet I am still
struggling to apply shellexecute to my own files.
Can someone please post a piece of code that will run MS Word and display
the contents of a file from "c:/my documents/college stuff/interlet.doc"
with the click of a command button.
Can the same code be applied to different file types i.e. files created in
word, access, powerpoint etc.?
Jul 17 '05 #17

P: n/a

"Roy Riddex" <ro**************@blueyonder.co.uk> wrote in message
news:vw****************@news-binary.blueyonder.co.uk...

1. Goto www.AllAPI.net
2. Download their API Guide
3. Look inside it for ShellExecute

Downloaded the API guide. Their example opens an email. Since I

haven't learned anything as advanced as shellexecute in college yet I am still
struggling to apply shellexecute to my own files.
Can someone please post a piece of code that will run MS Word and display the contents of a file from "c:/my documents/college stuff/interlet.doc" with the click of a command button.
Can the same code be applied to different file types i.e. files created in word, access, powerpoint etc.?


Their example opens an email because they specified
"mailto:KP*****@Allapi.net" as the file name. If you specify "c:/my
documents/college stuff/interlet.doc", then Windows will open that file,
with whatever program happens to be registered for .doc files (Word, no
doubt). Ditto for any file, if it has a registered file type.
ShellExecute is the programming equivalent of double-clicking on a file.
Jul 17 '05 #18

P: n/a
On Wed, 19 Nov 2003 21:36:54 -0800, "Steve Gerrard"
<no*************@comcast.net> wrote:

<snip>

Their example opens an email because they specified
"mailto:KP*****@Allapi.net" as the file name. If you specify "c:/my
documents/college stuff/interlet.doc", then Windows will open that file,
with whatever program happens to be registered for .doc files (Word, no
doubt). Ditto for any file, if it has a registered file type.
ShellExecute is the programming equivalent of double-clicking on a file.


Absolutely

However, the OP might also be interested in the FindExecutable API
- one gets a little more info on what is going on
- and a bit more control

Jul 17 '05 #19

P: n/a
Their example opens an email because they specified
"mailto:KP*****@Allapi.net" as the file name. If you specify "c:/my
documents/college stuff/interlet.doc", then Windows will open that file,
with whatever program happens to be registered for .doc files (Word, no
doubt). Ditto for any file, if it has a registered file type.
ShellExecute is the programming equivalent of double-clicking on a file.


Absolutely

However, the OP might also be interested in the FindExecutable API
- one gets a little more info on what is going on
- and a bit more control


Ok, this is really starting to take over my life now. It still doesn't seem
to work. I lifted the code straight from the API Guide and made the changes
as advised by Steve Gerrard. I'm unsure if the Private Declare Function part
is in the correct place(never used this before); I tried keeping it
alongside Private Sub cmdSelect but it was automatically moved above the
line and into the previous sub. I'm getting nearer to a difinitive answer,
please help.
Here's the part of my program causing me problems:

Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" Alias
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal
lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String,
ByVal nShowCmd As Long) As Long
Dim Password As String
Dim Counter As Integer
Dim HelpFile As String
etc.
etc.
Private Sub cmdSelect_Click()
Const SW_SHOWNORMAL = 1
ShellExecute Me.hwnd, vbNullString, "c:/My Documents/College
Subjects/ITAS/Word/Interlet.doc", vbNullString, "C:\", SW_SHOWNORMAL
End Sub
Jul 17 '05 #20

P: n/a
On Thu, 20 Nov 2003 12:16:53 -0000, "Roy Riddex"
<ro**************@blueyonder.co.uk> wrote:

Probably ... you need to surround things with quotes

Not sure

Look into the other thing I suggested, FindExecutable
(note: it needs a dummy file)
I'm rather stuffed now, an extended lunch

But tomorrow I'll probably do what I detest
- just post some code

Programmers should NEVER use code that they do not totally understand

Jul 17 '05 #21

P: n/a

"Roy Riddex" <ro**************@blueyonder.co.uk> wrote in message
news:Vg*****************@news-binary.blueyonder.co.uk...

Here's the part of my program causing me problems:

Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" Alias
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Dim Password As String
Dim Counter As Integer
Dim HelpFile As String
etc.
etc.
Private Sub cmdSelect_Click()
Const SW_SHOWNORMAL = 1
ShellExecute Me.hwnd, vbNullString, "c:/My Documents/College
Subjects/ITAS/Word/Interlet.doc", vbNullString, "C:\", SW_SHOWNORMAL
End Sub


This should work fine. I copied your code, substituted the path to a
file on my computer, ran it, and it opened up my word document straight
away. Maybe:
1. You are using forward slashes instead of back slashes, i.e. it should
be "c:\My Documents\College..."
2. Your path is not correct. On my XP machine, "My Documents" is
"C:\Documents and Settings\Steve\My Documents"
3. I assume the line breaks are from your mail program, and you have the
lines intact in your code. When you say it causes problems, it would be
more helpful if you specified what problem. Does it compile? Does it
run? Does anything happen? Do you get an error message?
Jul 17 '05 #22

This discussion thread is closed

Replies have been disabled for this discussion.