CD Autoplay - Is it possible to get it to run a program of my choice?

P

Palindrome

Hi,
As per the subject line - I would like to add my own "autoplay" so that,
whenever a CD is inserted, a program of my choice would run - automatically.

(The program that would run could be a batch file, or a Delphi .exe)

Can that be done and, if so, how?
 
P

Palindrome

Steve said:
Sue,

On the root folder of your CD, you need to place a text file named
Autorun.inf. If you know how to write batch files, I'm going to assume you
know how to create a text file with the extension inf rather than txt.

I can stop you there - they aren't my CDs. I just need to run my own
program whenever a CD is inserted. Any CD.

However, I've left your explanation below, as I am sure that it will be
of use to someone else - not to mention myself, should I need to produce
my own CDs.
The first line of autorun.inf should be
[AutoRun]

If you want a special icon to show in Windows Explorer when you insert this
CD, the next line should be:
ICON =
where the full path to the icon file follows the equal sign.

Next, you should have a final line that is
OPEN =
where the path and file name of an executable you want run follows the equal
sign.

There is an important caveat here. The file association information
contained in the registry won't be used when the "OPEN =" line gets read.
This means your exe file would run just fine, but if you want to run the
batch file, you should have the open line point to cmd.exe and then your
batch file listed as an argument to cmd.exe. If the batch file or exe file
you want run is also in the root folder of your CD, you don't need the full
path but you will need full path statements for exe files you reference that
are on your hard drive (this is where it can get even more tricky if you're
distributing the CD to people who might have key files located in atypical
folders on their hard drives).

It isn't a big deal but I prefer that someone getting a CD from me not have
to see the command (console) window flash briefly as cmd.exe is launched.
To avoid that, I prefer to use a vbScript file rather than a batch file. If
a vbScript file is used, you get it run using WScript.exe or CScript.exe
instead of cmd.exe. If you're good with html, you might also opt to create
an HTA file which makes available all sorts of tools to create an interface
for your users.
Thank you for the time that you have spent on the above, it was very
kind and much appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top