Creating Small Installers (Setup.exe + INF Engine)
Single Self-Extractor Setup Program , with
INF file (without any Dependency)
Author : Lalit K Chaudhary
E-mail :
Lalit_9876@yahoo.com
Requirement : You must Understand
Basic Setup Creation Using (InstallShield, Package & Development Wizard) or you
are an Application Developer, and able to Create Exe files for your
Applications, Using any Development Platform (VB, C++, VC++, Delphi,
PowerBuilder, JAVA or Even in Assembly) to Understand this Article.
Level of Difficulty |
1 2 3 4 5 |
|
Source Code for this Article |
None |
|
Introduction:
Did you had ever seen Setup.exe for Microsoft Toys [products
as DirectX, Runtime Environment for VB, VC, Service Packs, etc]. All those
products uses the Technology for it's Setup, which i am going to Describe in
this article. Believe me it's Simple that even an Average Developer can use this
Technology. The main Benefit is in terms of size of Setup, Because this
Technology uses INF script file as setup Script, and To Run an INF file you
don't need anything, because the Engine (SetupAPI.dll) Already Present in all
Version of Windows.
After Reading this article you will be able to Create single
SETUP.EXE (Containing Many files+1 INF File), and by running SETUP your
Application will be installed on the Computer.
Developer's Headache [How to Create Setup.exe]
Most of the Developers have a Major Headache of Creating
Stable and Reliable Setup or Installer for His/Her Application. You can easily
imagine the situation, when you know that My Application works fine on My
Computer, but when i tried to install it on another system, Sometimes it Works
fine, but sometimes behave unpredictable.
Current Scenario :
Generally Developers uses the Language Supplied Tool, Such as
for VB they uses Package and Development Wizard, or InstallShield, and for Power
Builder they uses such an Application.
So What is the Problems with these Tools :
The main Problem is with Size, Because they uses
Standard Install.exe, UnInstall. Exe with all the Setups which has all the
features for installing and uninstalling that you are using of nor, It works
based on an supplementary text file, this will Increase the Size of your Setup.
If you are creating a Setup which has to Configure Database
on Server, or such an Advanced Feature then you have to use Professional Tool
like InstallShield, or Microsoft Installer. For Simple Setups where you have to
Copy some files, to a Designated folder, Registering Dlls and OCXs, Creating
some Registry Entery, Creating Shortcuts on Desktop and Programs, you don't need
these Advanced Features. so you can use this Technique[ which i am going to
describing ].
So now, We are going to create Setup what you have seen as
most of Microsoft Products like DirectX , VB6 Runtime Setup etc.It is a single
EXE file running this will install the software on your computer. if you have
one of that file then try to do this. I am Assuming that you have VB6.0 Runtime
file Installer. Now Open this Exe in WinZip, you will see some Dll files and one
inf file. this INF file is your installer Script and other files are Packed
within single EXE file, Extract the inf file and open it in Notepad and Try to
Observe it.
Overview of Proposed Solution:
Here in this Article I am Going to Tell u another Easy,
Efficient way for creating Single Setup.exe
Creating Self Extractor Exe File :
to Create that Self Extractor Exe file we are using
IEXPRESS.EXE ,Try to find it on your Computer using find utility, if you
find it Run it, may Generate some errors that w95inf.dll not found, then this
will be found in any Self Extractor Setup such as DirectX setup or VB6.0 Runtime
Setup open it in WinZip and Extract the files needed, then Place it in
windows\System32 folder. If this Trick don't work then you have one choice, you
have to download IEAK SDK from Microsoft Search it and Download it from
Microsoft site.
By running this IEXPRESS.EXE, you will see that it is
a Wizard, In first step choose Create Self Extractor File. in next step
choose Extract File and Run installation command, Next Title of the
Setup, next is the Prompt like "This will install *** to your computer",
next is License if you want Provide a license Text file to it. In Next Step it
Ask for the files to be included in Exe, Add one or more files ( Program
Executable, Help Files, Dlls, OCXs, INF files for your installer or Uninstaller
[described in Next Section], and others), in Next Step you have to specify
Install and Post Install Program, Select install.inf for install command. Rest
can be used as default, one thing to remember is that you provide the Setup
Script file name (SED file, So that you don't have to for this wizard over and
over again, you can open the SED file in First Screen and Create the EXE again,
this will update all files and rest Setting will be same). Click next for all
the Pages and you See that your Self Extractor Setup will be Created, at the
location you Said.
Creating the INF file
In the Above Step you have Created a Self Extractor Exe file,
but it is not a Setup because it will extract all the files just like the Zip
file does. You have to create INF file to install your Application Properly.
In a Simple Setup Routine you have to do this :
-
Copy some files [Program and Help files], to a Designated
folder.
-
Delete some Files.
-
Registering Dlls and OCXs.
-
Creating some Registry Entery.
-
Deleting Some Registry Entery.
-
Creating Shortcuts on Desktop and Programs.
Get the Feel with Hello World INF Script:
Ö Source Code
: hello.inf |
; COMMENTS : Hello World from INF
; THIS WILL COPY HELLO.INF TO WINDOWS\HELLO FOLDER
; GOTO ADD REMOVE PROGRAMS, SEE HELLO WORLD ENTERY
; UNINSTALL IT. THAT'S ALL.
[version]
signature="$CHICAGO$"
; #### INSTALLER ####
[DefaultInstall]
CopyFiles=install.files
AddReg=add-registry-section
[DestinationDirs]
install.files=10,"Hello"
Delete.files=10,"Hello"
[install.files]
hello.inf
[add-registry-section]
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Hello",,,
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Hello", "DisplayName",0,"Hello World"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Hello", "UninstallString",0,"rundll32.exe
setupapi,InstallHinfSection DefaultUnInstall 132 %10%\Hello\Hello.inf"
; #### UNINSTALLER ####
[DefaultUnInstall]
DelReg=del-registry-section
DelFiles=Delete.files
[del-registry-section]
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Hello"
[Delete.files]
hello.inf |
Copy the above code in notepad and save it with named "Hello.inf" withour quotes.
How to Run INF File:
There are two ways to run INF script.
-
Open Dos prompt then type this command.
C:\>rundll32.exe setupapi,InstallHinfSection DefaultInstall 132 C:\Windows\Hello\Hello.inf
Here DefaultInstall stands for the section to be run.
and you need to supply the filename with path.
-
Right click the file (Hello.inf for instance) on Windows Explorer, and select Install from the Menu. Yes
just that easy.
NOTE : for Advenced Version of inf script file. you need to give the command
rundll32.exe advpack.dll,LaunchINFSection C:\Windows\Hello\Hello.inf, DefaultInstall But i suggest
you to create custom action on Explorer, as you have Install Command on explorer. to do so , Open Explorer > Folder
Opotions > File Types Tab, then Serach for the inf extension entery, Select it and click on the Advence button, new
window occurs, again click new button, there will be two text boxes, in action text box type "Install Advenced INF" and
in other text box type "C:\WINDOWS\System32\rundll32.exe advpack.dll,LaunchINFSection %1,DefaultInstall" Click OK and
close folder window. Now when you right click the inf file another item will appear on shortcut menu, as
you type it in action box, and by selecting this command you can run the INF script file of advanced Version also from
within explorer window.
Syntax of INF file :
You can Create INF file using any Text Editor, like
notepad, or Dos Edit.
Inf file is Divided in Sections, Some of them are
System Defined [Can not be changed, as version], and some are User Defined [
Developer Decide the name of Section, as install.files]. Section name must be
enclosed within [] as [version]. the order of the Section name is irrelevant.
Each Section have the Section Specific Entery.If more than one section in an INF
file has the same name, the system merges their entries and directives into a
single section.
comments can be placed as single line comment with
semicolon ; whatever after that is ignored.
inf file is Not Case Sensitive, so you can write
[version] or [VERSION] or even [version].
the Version Section is Mandatory and the signature must
be "$CHICAGO$"
Summary of INF Sections :
Version Section
This is a required section for every INF file. For installation on Windows
2000 and later, and/or Windows 9x/Me platforms, this section must have a valid
Signature entry.
DestinationDirs Section
Device/driver INF files have a DestinationDirs section to specify a default
destination directory for INF-specified copies of the files supplied on the
distribution media or listed in the INF layout files. This section is required
unless the INF file installs a device, such as a modem or display monitor, that
has no files except its INF to be installed with it.
SourceDisksFiles Section
This section identifies the locations of files to be installed from the
distribution media to the destinations on the target machine. An INF file that
has this section must also have a SourceDisksNames section.
SourceDisksNames Section
This section is required if the INF file has a corresponding
SourceDisksFiles section. This section is required to install IHV/OEM-supplied
devices and their drivers from distribution media included in packaged products.
It is also required in such an INF file that installs either of the following:
Strings Section
This section is required in every INF file to define each %strkey% token
specified in the INF. By convention, the Strings section (or sections if the INF
provides a set of locale-specific Strings sections) appears last in all
system-supplied INF files for ease of maintenance and localization.
DefaultInstall
The [DefaultInstall] Section is the Point where the Execution Begins, Under
this Sections there may be many SubSections some of the Important ones are
Name |
|
Description |
|
CopyFiles |
: |
This
directive references one or more file-list-sections specifying transfers of
model/device-specific driver images and any other necessary files from the
distribution media to the destination directory for each such file.
Alternatively, this directive can specify a single file to be copied from the
distribution media to the default destination directory.
|
|
DelFiles
|
: |
This
rarely used directive references one or more file-list-sections specifying files
to be deleted from the target of the installation.
|
|
RenFiles |
: |
This
rarely used directive references one or more file-list-sections specifying
INF-associated source files to be renamed on the destination
|
|
AddReg |
: |
This
directive references one or more add-registry-sections, which are INF sections
used to add or modify subkeys and value entries in the registry.
|
|
DelReg
|
: |
This
directive references one or more del-registry-sections used to remove obsolete
subkeys and/or value entries from the registry. For example, such a section
might appear in an INF that upgrades a previous installation.
|
|
RegisterOCXs |
: |
To
Register the Dll and OCX files, This will Create Registry Entery for your Dlls,
Same as RegSvr32.exe Does. |
|
Etc. |
: |
Actually there are many others, but that all are not necessary for this Job, so
i am Leaving others, If you want more Details Search in MSDN.Microsoft.com |
|
By now you must Got the knowledge for Creating Inf files,
Look Below i have provided sample inf files, Try to run this, Copy this to
notepad and save it to Sample.inf then right click the inf file in Explorer and
choose install, this will run the inf file, this may generate errors because it
is created for the Setup Exe file. But in this way you can create and try to run
and Debug INF files.
What here is Provided is the Foundation for Creating Self
Extractor Setup files with inf files, INF files can do much more, and all the
Device Driver is Developer uses it. I also Don't know much inner Details of it,
so that Help and Suggestion is Appreciated, For farther Query, Please Contact
me, Don't hesitate to Send a mail
Lalit_9876@yahoo.com.
Performing
Files [Coping, Delete]
Ö
Source Code : FilesCD.inf |
[version]
signature="$CHICAGO$"
; #### COPY FILESCD.INF TO WINDOWS ####
[DefaultInstall]
CopyFiles=all.files
; #### DELETE FILESCD.INF TO WINDOWS ####
; IT WILL NOT RUN AUTOMATICALLY, YOU NEED TO USE DOS PROMPT
; COMMAND AS SAID ABOVE, OT EDIT THIS FILE AND MAKE THE
; DefaultUnInstall TO DefaultInstall
[DefaultUnInstall]
DelFiles=all.files
[DestinationDirs]
install.files=10
[all.files]
FilesCD.inf |
Registery [Add, Remove Entery]
Ö
Register Extention .Form Using Registery :
Registery.inf |
[Version]
Signature=$Chicago$
[DefaultInstall]
AddReg=Register.Add.Reg
[DefaultUnInstall]
DelReg=Register.Rem.Reg
[Register.Add.Reg]
HKCR,.Form,,,"WebForms"
HKCR,.Form,"Content Type",0,"text/plain"
HKCR,WebForms,,,"Web Form"
HKCR,WebForms\DefaultIcon,,,"C:\1.ico"
HKCR,WebForms\Shell\Open\Command,,,"NotePad.exe"
[Register.Rem.Reg]
HKCR,.Form
HKCR,WebForms |
Dll,OCX [Register, Unregister]
Ö
Register Dlls Type 1 [Requires AdvSetup.dll] :
DllRegister1.inf |
[version]
signature="$CHICAGO$"
AdvancedINF=2.0
[DefaultInstall]
CopyFiles=install.files
RegisterOCXs=RegDLL.register
[RegDLL.register]
"%10%\MYAPP\MYDLL.DLL"
[DestinationDirs]
install.files=10,"MYAPP" ;WINDOWS\MYAPP
[install.files]
MYDLL.DLL
[MYDLL.DLL]
file-win32-x86=thiscab
RegisterServer=Yes
FileVersion=6,2,0,3 |
Although the above example is good, and works very fine but it requires that AdvSetup.dll must be
distributed within the setup.exe which is around 90K, If this is not what you are concerned then you should use it, but
there is another way to do so.
Actually when registering a DLL or OCX behind the scene window do some registery enteries, and what if
we do these registery entry's with our inf script. that's what i propose the second alternative to register DLL's, and
it don't require AdvSetup.dll.
Ö
Register Dlls Type 2 : DllRegister2.inf |
[version]
signature="$CHICAGO$"
AdvancedINF=2.0
[DefaultInstall]
CopyFiles=install.files
AddReg=RegisterDLLs
[RegisterDLLs]
HKCR,CLSID\%SGUID%,,,"MYDLL"
HKCR,CLSID\%SGUID%\InProcServer32,,,"%10%\MYAPP\MYDLL.DLL"
HKCR,CLSID\%SGUID%\InProcServer32,ThreadingModel,,"Apartment"
[UnRegisterDLLs]
HKCR,CLSID\%SGUID%
[DestinationDirs]
install.files=10,"MYAPP" ;WINDOWS\MYAPP
[install.files]
MYDLL.DLL
[Strings]
SGUID = "{A97820BA-DCC7-483A-B379-86993DE024CE}"
; TO DO THIS REGISTER DLL NORMALLY SEE IT'S EFFACT ON REGISTERY
; SIMULATE IT IN CODE
; AVOID USING THIS TECHNIQUE ON SHARED DLL'S |
Shortcuts [Programs, Deskop, SendTo, QuickLaunch, Startup]
Ö
Create Start>Programs Shortcut : CSStart.inf |
[Version]
Signature=$CHICAGO$
[DefaultInstall]
UpdateInis = SampleAddLinks
[SampleAddLinks]
setup.ini, progman.groups,, "Sample=LALIT"
setup.ini, Sample,, """My NotePad"", %10%\NOTEPAD.EXE" |
Ö
Create Desktop Shortcut : CSDesk.inf |
[Version]
Signature=$CHICAGO$
[DefaultInstall]
UpdateInis = SampleAddLinks
[SampleAddLinks]
setup.ini, progman.groups,, "Desktop=""..\..\Desktop"""
setup.ini, Desktop,, """My NotePad"", %10%\NOTEPAD.EXE" |
Ö
Create SendTo Shortcut : CSSend.inf |
[Version]
Signature=$CHICAGO$
[DefaultInstall]
UpdateInis = SampleAddLinks
[SampleAddLinks]
setup.ini, progman.groups,, "SendTo=""..\..\SendTo"""
setup.ini, SendTo,, """My NotePad"", %10%\NOTEPAD.EXE" |
Ö
Create Quick Launch Shortcut : CSQuick.inf |
[Version]
Signature=$CHICAGO$
[DefaultInstall]
UpdateInis = SampleAddLinks
[SampleAddLinks]
setup.ini, progman.groups,, "QLaunch=""..\..\Application Data\Microsoft\Internet
Explorer\Quick Launch"""
setup.ini, QLaunch,, """My NotePad"", %10%\NOTEPAD.EXE" |
Ö
Create Start>Programs>Startup Shortcut :
CSStartup.inf |
[Version]
Signature=$CHICAGO$
[DefaultInstall]
UpdateInis = SampleAddLinks
[SampleAddLinks]
setup.ini, progman.groups,, "Startup=""Startup"""
setup.ini, Startup,, """My NotePad"", %10%\NOTEPAD.EXE" |
Prompt User
Ö
Shows Message Box [Requires AdvSetup.dll] :
Prompt.inf |
[Version]
Signature=$CHICAGO$
AdvancedINF=2.5
[DefaultInstall]
BeginPrompt = Prompt.BeginPrompt
EndPrompt = Prompt.EndPrompt
[Prompt.BeginPrompt]
Prompt = "Want to Install"
Title = "Prompt User"
ButtonType = YESNO
[Prompt.EndPrompt]
Prompt = "Successfully Installed" |
Ask Destination Folder
Ö
Show Custom Folder Dialog [Requires AdvSetup.dll] :
FilesCD.inf |
[Version]
Signature=$CHICAGO$
AdvancedINF=2.5
[DefaultInstall]
CustomDestination=InstallCustomDestination
[AppCustomDestination]
HKLM,"SOFTWARE\CG",'InstallDir',"Install Where","%24%\CG"
[DestinationDirs]
all.files=49000
[InstallCustomDestination]
; Custom app directory, flag 1 means prompt user
49000=AppCustomDestination,1 |
Updating Autoexec.bat, Config.sys
Ö
Source Code : EAutoExec.inf |
not yet prepared, wait. if you have please mail me |
Ö
Source Code : EConfig.inf |
not yet prepared, wait. if you have please mail me |
SAMPLE install.inf file
Ö
Source Code : install.inf |
[version]
signature="$CHICAGO$"
AdvancedINF=2.0
[DefaultInstall]
CopyFiles=install.files
RegisterOCXs=RegisterFiles.register
AddReg=add-registry-section
[DestinationDirs]
install.files=16422,"MYAPP" ;IN PROGRAM FILES
[install.files]
MYAPP.EXE
MYAPP.HLP
MYDLL.DLL
MYAPP.DAT
README.TXT
UNINSTAL.inf
[RegisterFiles.register]
"%16422%\MYAPP\MYDLL.DLL"
[add-registry-section]
HKLM,"SOFTWARE\MYAPP",,,
HKLM,"SOFTWARE\MYAPP","KEY1,0,"DATA1"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion
\Uninstall\MYAPP",,,
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion
\Uninstall\MYAPP","DisplayName",0,"MYAPP"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
\MYAPP","UninstallString",0,"rundll32.exe setupapi,InstallHinfSection
DefaultInstall 132 %16422%\MYAPP\Uninstal.inf"
[MYDLL.DLL]
file-win32-x86=thiscab
RegisterServer=Yes
FileVersion=1,1,0,6 |
SAMPLE Uninstall.inf file
Ö
Source Code : uninstall.inf |
[version]
signature="$CHICAGO$"
AdvancedINF=2.0
[DefaultInstall]
UnregisterDlls=Unregister.server
DelReg=del-registry-section
DelFiles=Delete.files
[DestinationDirs]
Delete.files=16422,"MYAPP"
[Unregister.server]
16422,MYAPP,MYDLL.DLL,1
[del-registry-section]
HKLM,"SOFTWARE\MYAPP"
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\MYAPP"
[Delete.files]
MYAPP.EXE
MYAPP.HLP
MYDLL.DLL
MYAPP.DAT
README.TXT
[MYDLL.DLL]
file-win32-x86=16422,"MYAPP"
RegisterServer=Yes
FileVersion=1,1,0,6 |
Hope this will help you? Have question, don't hasitate ask me!
and Please forgive me for my TYPOS.
|