Page 1 of 1

boot application from CD

Posted: 22 Nov 2010 22:58
by sorcerer
Hello all,
I have some files to be burnt onto a folder in a CD.
In order to read these files, I am going to put an application, say ABC.exe, on the root directory of the CD.
All the dlls, required for ABC.exe will be sitting in the root directory as well.
When the CD is inserted onto the computer, I would like the application to run automatically. Once this application starts, then using the user interface of this application, the user can open the files in the directory using this application.
I am absolutely new to DOS scripting.
Would someone please tell me whether the script below can do the job please?
I believe this script will kick off ABC.exe and then close the DOS window (hence @EXIT).
Should this file be saved as a .bat file or .ini file?

@ECHO OFF
start ABC.exe
@CLS
@EXIT

Thanks in advance.
Sorcerer

Re: boot application from CD

Posted: 23 Nov 2010 00:15
by orange_batch
What you want is an autorun.inf file in the root of the CD. Keep in mind it will only autorun if Windows has it enabled.

http://en.wikipedia.org/wiki/Autorun.in ... le_example

Code: Select all

[autorun]
open=setup.exe
icon=setup.exe,0


Code: Select all

[autorun]
shellexecute=myscript.bat

Re: boot application from CD

Posted: 23 Nov 2010 17:21
by sorcerer
Thank you OB.
Quick questions. Why is setup.exe,0 is listed on the line for icon. Should that be an icon file instead? And what does "0" do?
There is no distinct advantage between the two methods you suggested. Correct? You are just demonstrating that I can use a batch file to start an app using an inf file. Correct?

Re: boot application from CD

Posted: 23 Nov 2010 18:12
by orange_batch
I think an .ico file can contain only 1 icon? Either way, many .exe's contain a number of icons within them. The ,0 represents the index of which icon to use from an .exe. You can see this when you create a shortcut and change the icon. .dlls also do this (for example, C:\WINDOWS\system32\SHELL32.dll).

shellexecute will open any file based on the program it's extension is associated with in Windows. (Like .htm will open the file in your default browser.)

I'm not sure if open is different, but given that I'd assume it's only good for running an .exe program directly? However, it's the recommended way to autorun an .exe. I would recommend it too since it probably doesn't have to go through as many hoops with the OS.

So if you just want it to autorun an .exe, use the first example. If you want to open any other file, or run a batch script that does a bunch of different things, use the second example.

As the link I made to Wikipedia says,

open=[exepath\]exefile [param1 [param2 ...]]
Specifies the path, file name and optional parameters to the application that AutoRun launches when a user inserts a disc in the drive. It is the CreateProcess function that is called by AutoRun.
shellexecute=[filepath\]filename [param1 [param2 ...]]

Windows 2000, Windows ME or later

Similar to open, but using file association information to run the application. The file name can therefore be an executable or a data file. It is the ShellExecuteEx function that is called by AutoRun.