![]()
4. Setup and Deployment Projects
Whenever we download any
software from the net for the Windows operating system, it comes crammed in a
single file. This file invariably has the extension of .zip or .exe or .msi, or
.cab, etc. The zip file is a compilation of multiple files, which may or may
not be in a compressed form. It requires an unzip program, one of them called
'Winzip', to extract the files from the zip mode. An exe file is an executable
file, which requires no external program, and can run on its own. However, the
msi file, which contains an installation program, requires a Windows Installer
program.
When a product has to be
installed on the hard disk, the file that initiates the installation program,
either has an 'exe' extension (for e.g. setup.exe) or a msi extension. This
program brings forth a wizard, where relevant information has to be entered,
for successful installation. The program also checks for the essential harddisk
space and a location where the files are to be ensconced. At times, it may even
call upon you to reboot the system.
Let us consider the case of any
one of the software companies that we know. While a product is being developed,
it allots the development of certain features to each one of the software
programmers in the project team. Thus, by the time the product is ready, there
are numerous files containing the source code, which need to be referred to. It
is an awfully tedious and irksome exercise to merge all the files into one
file. Besides, the files need to be placed in certain directories, for the
program to be able to function as desired. The program may also want to add a
Program Group to the Start menu and make amendments to the System Registry.
Therefore, to make life a lot easier, a Setup program is developed, which
contains a wizard that eases the job of deploying the project.
This chapter focuses on the
Setup and the Deployment issues. It delves upon how life has become much more
comfortable and snug, with the inbuilt features of the .Net framework, which
buttress these issues. This setup program is accorded an extension of 'msi',
under Windows.
As is normally done, you need to
ensure that all the windows and projects are closed in Visual Studio.Net. Now,
click on the menu File - Project - New. In the New Project dialog box, choose
the Setup and Deployment option in the Project Types pane and Setup Project in
the Templates pane. Enter the name of the project as 'y1' and the location as
c:\vijay. The screen 4.1 displays these selected options.
|
|
|
Screen 4.1 |
After clicking on the OK button,
we arrive at screen 4.2. The screen doesn't appear very familiar.
|
|
|
Screen 4.2 |
It would be a good idea if you
too, would click on the View menu and select the Solution Explorer option. This
would bring-in the Solution Explorer window on the extreme right, as is evident
in screen 4.3.
|
|
|
Screen 4.3 |
Let us concentrate on the type
of applications that we are working with.
Earlier, we had clicked on the
Debug menu, and then on Start. However, in case of the Setup project, the Start
menu item is disabled, as shown in screen 4.4.
|
|
|
Screen 4.4 |
This obviously implies that we
cannot run a setup program. Instead, it has to be built. Therefore, we click on
the Build menu, and then, again on the menu option named Build, as seen in
screen 4.5.
|
|
|
Screen 4.5 |
It is evident from the output
window that the build has succeeded. So, how do we establish whether things are
shaping-up the way we want them to?
Double click on the My Computer
icon on the Desktop and then, click on 'c drive'. Here, double click on the
'vijay' sub-directory, since this is the location that we have specified for
all our projects. Amongst the other subdirectories, is the subdirectory of y1.
Open up this folder by double clicking on it, and then, double click on the
'debug' subdirectory. Here, you would arrive at the installer program y1.msi.
|
|
|
Screen 4.6 |
Double click on the file y1.msi
and view your screen, while the install program is running. Without writing a
single line of code, we have created a setup wizard for y1. Screen 4.7 confirms
this fact. Click on the Next button to arrive at screen 4.8.
|
|
|
|
Screen 4.7 |
Screen 4.8 |
The default sub-directory, to
which the files will be copied, is shown as C:\Program Files\VMCI\y1\ . If you
are not too pleased with this location, click on the Browse button. This will
lead you to a 'Directory Change' dialog box, as can be seen in screen 4.9.
|
|
|
|
Screen 4.9 |
Screen 4.10 |
Click on Cancel, in case you
decide to change your mind, and carry on with the subdirectory assigned by
default. This is exactly what we have done. This reverts us back to the
previous screen, where we now click on Disk Cost.
The Disk Cost button reveals a
dialog box, as is apparent in screen 4.11. This dialog box displays the
currently available drives on our machine, together with the size and space
available on each of them, and the space required for the current installation.
In spite of there being no files to be copied, the screen displays a
requirement of 202K for our installation. Click on the OK button to close the
dialog box. Once done, click on the Next button.
|
|
|
|
Screen 4.11 |
Screen 4.12 |
The screen that comes to the fore,
asks for the final confirmation for the installation of the files, which are
present in the installer package.
No sooner is the Next button
clicked upon, does a screen spring up, showing a progress bar that indicates
the proportion of installation that has been completed so far.
Once the files have been
installed, the screen changes to the one reflected in screen 4.13, reporting
the successful completion of the installation. Clicking on Close will take us
out of this last dialog box of the wizard.
|
|
|
Screen 4.13 |
Now, in order to verify and
identify the files installed by the installation program, we venture into the y1
sub-directory, within the VMCI sub-directory in Program Files.
To our utter dismay, no
subdirectory by the name of y1 meets the eye. This makes sense, since the
installer was not called upon to copy any files at all. As there were no files
to be copied, there obviously wasn't any need to create a sub-directory.
Double click on the y1.msi icon
again. We expected the same wizard to execute again. But, we were startled to
find the screen displaying buttons to 'Repair' or 'Remove' the installation.
|
|
|
Screen 4.14 |
The default option selected is
that of 'Repair'. This option is of great utility in situations where we may accidentally
delete a file. In such circumstances, we may merely wish to copy the deleted
file, instead of wasting a lot of time in reinstalling the whole package. The
repair option is most ideal for handling such situations.
In the case of this particular
application,we would rather undo the installation. Hence, we select the
'Remove' option and then, click on the Finish button. As always, the next
screen that appears, shows a progress bar indicating the proportion of the task
that has been completed. Once the task is over, the screen containing the Close
button, is displayed.
We shall pursue the following
approach for the setup programs:
• After making the requisite modifications, we shall build the project.
• Then, we shall run the installation program to install the files.
• Thereafter, we shall examine the changes.
• Ultimately, we shall run the installation program once again, to remove the installation.
This will ensure that we start
afresh each time.
A question that torments our
minds is, 'What would the installer
program do to keep itself occupied, when we do not give it any files to be
copied?'.
You would be able to obtain the
answer, after executing the following steps:
• Run the installer program once again, by clicking on the msi file.
• Browse through the wizard in the same way, as was done before.
• From the Start menu (Ctrl+Esc), choose Settings, and then, select the Control Panel.
• Double click on the icon for 'Add/Remove programs'.
• Scroll right down till you see 'y1' in the window.
The screen 4.15 shows the 'y1'
program, amidst the list of programs that have been installed.
|
|
|
Screen 4.15 |
Thus, the installer has
registered our program with the Windows Installer. This is the reason why it
figures in this list. Close the Add - Remove Program dialog box and Re-run the installer
program in order to remove the program. Now, if you check the Add/Remove
Program in the Control Panel, you will find no traces of the program.
Thus, the installer program not
only displays the wizard containing the entire set of dialog boxes, which
facilitate copying or removing the files, but it also registers/unregisters the
program with the Windows installer.
Now, you may incorporate a
slight modification to the project. Bring up the Properties window by pressing
F4. Choose the property called ProductName, and change its value to y11. This
is shown in screen 4.16.
|
|
|
Screen 4.16 |
Then click on Build - Build to generate
the application. Then, run this installer program from the Debug sub-directory,
and click on the Next button of the first screen. You will arrive at screen
4.17, where the name of the sub-directory is depicted as y11.
|
|
|
|
Screen 4.17 |
Screen 4.18 |
We will not persist with the
installation, because no directories would be created, owing to the fact that
there are no files to be copied. So click on the Cancel button. This does not
terminate the installation immediately as it asks for final confirmation. Since
we are sure that we want to exit the installation, we shall click on the 'Yes'
button, and the last screen of the Wizard is displayed, indicating the
installation status, before bidding adieu. The screen 4.18 reveals that the
installation had been interrupted. Click on the Close button to end the
installation. Since the modus operandi is to focus on a single feature at a
time, we will cancel the installation after displaying and explaining the
relevant portions. This saves the effort of uninstalling the application each
time.
Now, we change the value of the
Manufacturer property to 'sonal'. Also, instead of clicking on the Build menu
option, followed by Build again, we will use the short-cut key Ctrl-Shift-B.
Run the project, and then, click on Next button of the first screen. The screen
that appears next is shown in screen 4.19. Notice that the subdirectory name
after Program Files has changed from VMCI to sonal.
|
|
|
Screen 4.19 |
Cancel the installation. Now,
let us make fresh modifications to the project. In the window, the first two
panes are referred to as the File System Editor. As soon as we click on the
Application folder in the first pane, the second pane goes absolutely blank.
This is by reason of there being
no files in this folder. For verification, you can view the screen 4.20.
|
|
|
Screen 4.20 |
We now wish to place a file
named 'a.txt' in this folder. So, first create a file called a.txt containing
whatever text you desire, in the root of C drive. You can use any program that
would assist you in creating this file.
Once this is accomplished, right
click on the Application folder, as shown in screen 4.21. This will display a
popup menu, which is context sensitive.
|
|
|
Screen 4.21 |
Remember the following cardinal
rule in Windows: "If ever you feel lost, click the right mouse button, and
you will be enlightened about the activities that you are allowed to carry out,
in your present position."
Since we want to Add something,
we move the mouse over the Add option. This is showcased in screen 4.22. Many
of the items displayed with the Add option can be added to the Application
folder. We select the File option, since presently, we are keen on learning how
to add Files to the Application Folder.
|
|
|
Screen 4.22 |
Now in the familiar File dialog
box, navigate to the root of C drive, and choose the freshly minted file a.txt
by double clicking on it. The screen 4.23 clearly delineates this act of ours.
|
|
|
Screen 4.23 |
Once the file has been selected,
we revert back to the panes in the window. Screen 4.24 unfolds two changes,
which have been effected because of our earlier actions.
|
|
|
Screen 4.24 |
The file name a.txt makes an
appearance in both, the second pane and the Solution Explorer. Press
Ctrl-Shift-B to build the program. But, before running the program, delete the
file a.txt from the c drive. This goes on to prove the fact that this file is
dispensable, since the installer has included a copy of it in the file y1.msi,
while building it.
Now, we adopt a different
strategy to run the installer. In the Solution Explorer, choose the project y1,
and not the solution, and right click on it. From the list of options
displayed, select the Install menu option.
|
|
|
Screen 4.25 |
Now, execute the installation in
its entirety. Then, go to the program files sub-directory to ascertain if a
sub-directory called 'sonal' has been created with y11. Now, go to the
sub-directory y11, where you will see a file called a.txt. Thus, the
installation program has successfully copied the file a.txt into the requisite
sub-directories of the target machine.
Now, on pressing the keys
Ctrl-Shift-B, trouble brews, as shown in screen 4.26. The problem here is that,
since we deleted the file a.txt from our machine, it could not get added to the
file y1.msi. Thus, we need to create it once again.
|
|
|
Screen 4.26 |
Click on the right mouse button
after selecting y1 in the Solution Explorer, and then, select the UnInstall
menu option. Before the product begins uninstalling, a message box appears on
the screen, trying to verify our sanity (as shown in screen 4.27).
|
|
|
Screen 4.27 |
Once our sanity has been
established, and we are absolutely certain that we want to uninstall the product,
we click on the 'Yes' button. The process of un-installation gets executed
without much ado.
If you attempt to uninstall the
product once again, the same box pops up, requesting for confirmation. On
clicking the 'Yes' button, another message box emerges (as shown in screen
4.28), apprizing us of the fact that the unistall procedure works only on
installed products. This proves that the installer is highly active and aware
of the current state of the product, and has sufficient built-in intelligence.
|
|
|
Screen 4.28 |
Select the Application folder
tab once again, and click with the right mouse button on the file a.txt. The popup
menu is displayed, as expected. Select the option of 'Create Shortcut to
a.txt'. This will reveal a screen, as seen in screen 4.29.
|
|
|
Screen 4.29 |
You can see that an entry has
been made. Now, change the name of the shortcut to 'vijay'.
|
|
|
Screen 4.30 |
Select the shortcut 'vijay' and
drag-and-drop it into the folder labeled User's Desktop, in the first pane. On
doing this, the screen 4.31 is exposed to our view.
|
|
|
Screen 4.31 |
Most install programs copy a
shortcut on the desktop. Whenever we click on a short cut, the program or the
application associated with it gets executed. After recreating a.txt in the
root, press Ctrl-Shift-B to build the project. Then, right click on the y1
project in the Solution Explorer, to select the Install menu option from the
popup menu. Henceforth, we shall simply request you to 'run the installer',
rather than reiterating these steps over and over again.
Once the installation is
effected, click on the Close button and switch to the desktop. You will see the
newly created icon named 'vijay', amongst the other icons on the desktop. Thus,
we can copy a single file, as well as, multiple files and even shortcuts to the
desktop. Right click on the shortcut named 'vijay', and select the menu option
called Properties. Screen 4.32 shows the desktop that exists on our machine.
|
|
|
Screen 4.32 |
A dialog box will popup, (as
seen in screen 4.33), which divulges relevant details about the shortcut.
|
|
|
Screen 4.33 |
Close the dialog box and double
click on the shortcut. The notepad application opens up, with the file a.txt
displayed in it. The screen 4.34 shows the file a.txt in notepad.
|
|
|
Screen 4.34 |
Close notepad and switch to Visual
Studio.Net framework. Uninstall the application by following the same steps
that have been stipulated earlier. The Installer not only uninstalls the
application, but it also deletes the shortcut from the desktop. Thus, the
uninstall option eliminates each and every resource installed by the
installation program. Therefore, the
subdirectories that were created, such as, 'sonal' and y11, shall also be
deleted. However, while uninstalling, if these subdirectories are in use, then
they shall not be deleted.
Click on the application folder
and select the file a.txt. Select the 'create shortcut' option once again, and
rename the shortcut to 'Mukhi'. Then, select 'Mukhi' and drag-and-drop it
inside the folder called User's Program Menu. The screen 4.35 displays the
shortcut in the User's Program Menu.
|
|
|
Screen 4.35 |
Press Ctrl-Shift-B to build the project,
and then, run the installer. Once the installation has been concluded, click on
the Start Menu (Ctrl+Esc), and go to the Programs option. Having selected
Programs, the programs that can be executed under this option, are exhibited.
Within it, the option 'Mukhi' is also displayed. It gave us great satisfaction
to see the screen, which is shown in the screen 4.36.
|
|
|
Screen 4.36 |
Clicking on 'Mukhi' will lead us
to the a.txt file in notepad. Thus, the installer program has been able to add
a menu to the user's menu. If you uninstall the program, the menu called
'Mukhi' also disappears.
The next modification
illustrates how a particular File Type can be associated with an Application.
The imperative task on hand is, to ensure that the installation program
registers the file extension 'bbb' with the Wordpad application. This is to
ensure that, each time we click on a file with an extension of 'bbb', the
Wordpad application should start and display the contents of this file.
Select the Application folder,
and click on the right mouse button. Now, select the Add menu option and the
File option. This was demonstrated earlier, while adding the file a.txt.
This brings up the Add File dialog box,
as was evident earlier too. Navigate to the Accessories directory from Program
Files and then, select Wordpad.exe. This will ensure that both, WordPad and
a.txt, are copied to the target computer.
|
|
|
Screen 4.37 |
In the root of C drive, create a
file called b.bbb, which could contain just about anything under the sky. Once
the file has been created, choose the Application folder yet again, and right
click on Add, followed by File, to add the file b.bbb.
The second pane for the
application folder now displays three files: a.txt, b.bbb and Wordpad.exe. Once
the required files have been incorporated, select b.bbb and click the right
mouse button. Then, choose the Create Shortcut menu option and rename it as
'sunny'. Now, drag-and-drop the shortcut 'sunny' into the User's Desktop tab,
which should now contain two shortcuts, shown in the screen 4.38.
|
|
|
Screen 4.38 |
Once this is accomplished, click
on the View menu, and then, on the Editor option. This will list down six
different editors, which are clearly visible in screen 4.39.
|
|
|
Screen 4.39 |
We are currently working on the
File System editor. Choose the menu option File Types, and you will be greeted
by a fresh screen, as gleamed in screen 4.40.
|
|
|
Screen 4.40 |
You may also notice that there
are two tabs on the screen for each of the editors. These tabs facilitate easy
switching between the editors, on an as-required basis.
Right clicking on the File Types
item, displays only one menu item, i.e. Add File types. This can be seen in the
screen 4.41.
|
|
|
Screen 4.41 |
On selecting Add File types, a
few more options appear under File Types. This is seen in screen 4.42.
|
|
|
Screen 4.42 |
You may assign any name to the
new file. We have assigned 'azz' as the name. Pressing F4 will exhibit the
properties of this type.
|
|
|
Screen 4.43 |
For the Extensions property,
specify the extension of bbb. Now, to associate a program name with the extension
bbb, click on the 3 dots i.e. ... , of the command property.
A dialog box, as shown in screen
4.44, crops up with the same three items, as shown in the FileSystem. We are
apprized of the fact that, Wordpad.exe is located within the Application folder.
Hence, we double click on Application Folder and select Wordpad.exe from it.
|
|
|
|
Screen 4.44 |
Screen 4.45 |
The command property now shows
Wordpad.exe. Before proceeding any further, let us determine whether things are
taking shape the way we want them to. So, build the project, and then, run the
installer.
The installation is completed
successfully. On the desktop, two shortcuts named 'sunny' and 'vijay' are
visible.
Double click on 'sunny'. Lo and
behold! WordPad opens up, displaying the file b.bbb.
|
|
|
Screen 4.46 |
The screen 4.46 endorses our statement.
Thus, any file with the extension of bbb, has now been associated with
Wordpad.exe, without having to write a single line of code.
Let us verify this association.
Create a file c.bbb in the root of C drive. Then, create a shortcut to it on
the desktop. In order to create a shortcut, right click on the desktop and
select Create Shortcut. This shows the Create Shortcut dialog box, wherein, we
are asked to enter the name of the file. Obedient as we are, we enter the name
c.bbb, which is our newly created file.
Keep clicking on the Next button
repeatedly, till you come to the Finish button. On clicking the Finish button,
the shortcut named c.bbb will be displayed on the desktop.
We see the shortcut in screen
4.47. It has an icon identical to that of a file associated with Wordpad.
Though it appears distinct from 'sunny', when we click on it, the Wordpad
program opens up with the file.
|
|
|
Screen 4.47 |
Uninstall the project and revert
back to the desktop. You will see that the two shortcuts that were created
earlier have disappeared. Now, on double clicking c.bbb, a dialog box appears,
as shown in screen 4.48.
|
|
|
Screen 4.48 |
This dialog box turns up because
Windows has no clue as to which application to use to open a file with the
extension of bbb. This substantiates the fact that the installer, while
uninstalling a product, also removes the file association. However, we are clueless
as to how it performs this task.
Each time we install some
software, we would want to ensure that the user's machine already has a
specific version of a software package installed on it. To implement such a
condition, we use the editor called Launch Conditions. Click on the View menu,
then move the mouse to the last editor named Launch Conditions. This is shown
in screen 4.49.
|
|
|
Screen 4.49 |
Once the editor has been
selected, you will arrive at screen 4.50.
|
|
|
Screen 4.50 |
The screen now shows three tabs,
amongst which, the Launch Conditions editor tab is active. Here, select
'Requirements for Target Machine', and click the right mouse button. Select the
first option named 'Add File Launch Condition'.
|
|
|
|
Screen 4.51 |
Screen 4.52 |
One child node gets added to
each of the two parent nodes. Our primary focus will be on the Properties
window for the node Search for File1. Select Search for File1 and in the
Properties window, modify or initialize the properties, as described in the following
text.
Start with the Folder property,
and click on the listbox to see a list of directory names. We want to ensure
that a specific version or any higher version of Internet Explorer exists on
the user's machine. The exe file for Internet Explorer is Iexplore.exe. So,
choose the option of [ProgramFilesFolder], since it is located in the
sub-directory Internet Explorer, within Program files.
The next property to be modified
is called Depth. The Depth property refers to the number of sub-directories under
Program files, which should be searched to locate a particular file. In our
case, we know that it is more that one directory deep. So we select the depth
accordingly. The most important property is the FileName. It has to be assigned
the filename, whose version needs to be ascertained. Thus, we set the FileName
property to Iexplore.exe.
We also desire that the Minimum
version of Internet Explorer should be at least 7.00. So, we assign a value of
6.00 to the Minimum property. The property window on your screen should
resemble screen 4.53. Now, build and run the application
|
|
|
Screen 4.53 |
The message box that emerges, does
not inspire any confidence in us, since it only reads 'Error Message'. A click
on the OK button too, doesn't assist much in determining the cause of the
error, since the window only informs us that the installation did not occur due
to some problem.
Wouldn't life be much easier, if
the error messages were a trifle more meaningful? To ensure this, click on the
second child node named Condition1 and then, select the Message property. Here,
enter the appropriate error message as follows: 'Wrong Internet Explorer
Version Number'.
Now, build the project and
install it. Screen 4.54 displays the error message, which we have just entered.
|
|
|
Screen 4.54 |
The error occured because the
installer expects the version number of Internet Explorer to be at least 7.00.
Most of us would either be working with Internet Explorer 5.5 or with 6. So,
set the Minimum version to 5.00, and everything will work just fine, as before.
The value of the Maximum version can also be set, which will guarantee us that
the Internet Explorer version falls within a range of the Minimum and Maximum
values.
Now, we shall look into
customizising the User Interface. Click on the View menu option, and from the
Editors option, select User Interface. The screen that is displayed, will look
similar to what we have shown in screen 4.55.
|
|
|
Screen 4.55 |
It is in this editor that we can
customize the User Interface, or the screens that the installer displays. So
far, we have always skipped the first screen that is displayed during the
installation process, by pressing the Next button. This is because, it does not
have much significance for us. So, let us remove it. To do so, select the
Welcome node, right click on it, and select the Delete option. This is shown in
screen 4.56. You will see the node disappear.
|
|
|
Screen 4.56 |
Build the project and install
it. The Welcome screen is not exhibited any longer. Thus, we can customize
every single aspect of the User Interface. After having reviewed the changes,
cancel the installation midway, or else, you will have to go through the entire
uninstallation procedure.
How do we go about adding our
own dialog box? This can be done as follows: Select the Start node and then
right click on it. Then, choose the menu option of Add Dialog, as shown in
screen 4.57.
|
|
|
Screen 4.57 |
Here, in a dialog box, we are
provided with a gargantuan list of the possible dialog pages, which we can add
to our User Interface. Now, select CheckBoxes(A), as revealed in 4.58.
|
|
|
Screen 4.58 |
On doing so, a screen will show up,
as displayed in screen 4.59, where a checkbox will be displayed at the bottom.
Further, this screen is added in the third position in the list.
|
|
|
Screen 4.59 |
This sequence of displaying the
screens is just not acceptable to us, since we would like our freshly added
dialog box to be the first screen to be displayed. Don't sweat the small stuff!
Just right click on the node, and select the option of 'Move up', as shown in
screen 4.60. Repeat this process once again, to move the dialog box to the top
most position.
|
|
|
Screen 4.60 |
Now that the ordering is as per
our taste, we need to build and then,install the project. screen 4.61 displays
four checkboxes and some text. Clicking on the Next button will take you, yet again,
to the dialog pages that you had viewed earlier. We may append as many dialog
pages as may tickle our fancy.
|
|
|
Screen 4.61 |
We shall now customize the
displayed dialog page. Press the Cancel button, and ensure that the CheckBoxes
dialog node is selected.
Firstly, in the Properties
window, change the Banner Text to 'First Screen', and in the Body Text, change
it to 'Select the options displayed below'.
Then, glide down to the
properties of CheckBox2Visibile, CheckBox3Visibile and CheckBox4Visibile. For
each of them, click on the drop down listbox and select the value of False.
This action of ours, ensures that the last three checkboxes do not get
displayed at all. Screen 4.62 shows the Properties window, with the newly
assigned values.
|
|
|
Screen 4.62 |
Once the project is built and
installed, the screen that we arrive at, flashes the title as 'First Screen'.
The Body Text also contains the newly assigned value, and just a single check
box is displayed.
|
|
|
Screen 4.63 |
Now, we want to employ this
checkbox to determine whether the file a.txt needs to be copied or not. This will
make our installation program much more flexible, as it will empower the user
with the option of selecting the files that need to be copied. If the checkbox
is selected, the file will get copied, otherwise not. Click on the Cancel
button to initiate this modification.
Click on the node Checkboxes
(A), and take a look at the Properties window. The property Checkbox1Property
will reveal its value as CHECKBOXA1.
Now, click on the first tab
named File System, and then, on the Application Folder. Select the file a.txt
in the second pane, and for the first property Condition, enter CHECKBOXA1 = 1,
Sereen 4.64. Thus, we have made the process of copying a file conditional; in
that, the file will be copied only when the checkbox is selected.
|
|
|
Screen 4.64 |
Build the project and install
it. The first screen displays the checkbox, as seen earlier. Leave the checkbox
unselected, and complete the installation. It is time to verify whether the
condition took effect or not. In the subdirectory y11, within the sonal
directory, there are two files visible, instead of three.
Now, uninstall the project and
reinstall it. This time, you must ensure that you click on the checkbox and
complete the installation. On navigating through the sub-directories, it would
become amply evident, that the file a.txt has been copied.
Thus, we have demonstrated a
mechanism used very often by an installer program, wherein, a list of options
is displayed; and the user has the discretion of selecting the options that he
wishes to install on his machine.
There is no necessity for
retaining the condition for a.txt anymore. So, delete the condition, and switch
back to the User Interface, in order to append a few more dialog boxes. Delete
the Checkbox Node and thereafter, right click on the Start Node. As expected,
the popup for the Add Dialog is displayed. This time, select the 'Read Me'
Dialog.
Every installation program
furnishes a Readme file, which embodies information for the user to read,
either before proceeding with the installation or after completing it. It may
contain details about the product, its requirements, the author's name, etc.
Start the Word application, and
in a blank file, enter 'Hello everybody'. Then, to save the file, click on
File, Save As and select the file type as 'Rich Text format' or RTF file. The
file is named aaa.rtf in the root of C drive. The dialog box displays the
options selected in screen 4.65.
|
|
|
Screen 4.65 |
Close the Word application. Next,
for the sake of consistency, right click on the ReadMe node, and move it up two
notches, in order to make it the first node. It therefore becomes the first
dialog box to be displayed. In the Properties Window, click on the Down Arrow
of the property ReadMeFile, and select the Browse option.
|
|
|
Screen 4.66 |
The dialog box of ‘Select Item
in Project’ pop’s up. We have bumped into
this dialog box before. Therefore, there is no need to replicate the
explanation.
If you select the Application
Folder, you will obtain a blank screen, since there are no files having the
.rtf extension, in our Application Folder. All the files that are required to
be copied to the target machine, are lodged in the Application Folder. So far,
none of the three files, has an extension of .rtf. So, click on the button labeled Add File in the dialog box, and
choose the file aa.rtf, residing in the root directory.
|
|
|
Screen 4.67 |
Once this is done, click on OK Button,
and monitor the file aa.rtf, being assigned to the ReadMefile property.
Here, we take a short detour,
and click on the File System tab. Open the Application Folder. You will notice
that this file has not been added to the present list of files.
Build the project and install
it, in order to view the outcome of our handiwork. Screen 4.68 displays the
Readme file, aaa.rtf, containing the text that we had entered.
|
|
|
Screen 4.68 |
Deleting the file from C drive
will not result in any errors, since a copy of the file aaa.rtf has been
incorporated within the msi file. You may recall, that a similar approach was
adopted while the file aa.txt was being copied.
Thus, if you want to subsume a
file within the installer program, however, you do not want this file to be
copied during the installation, just pursue the methodology stipulated above.
In this manner, you can keep a few select files, away from the prying eyes of
the users.
Cancel the installation, since
we do not intend to proceed any further. As we have finished dealing wiith the
ReadMe node, click on the node, and then, press the Delete key to banish it.
Now, let us handle the License
Agreement dialog box. As usual, right click on start, and then, click on 'Add
Dialog' to raise-up this dialog box from the list that is displayed. Shift it to
the first position, and then, select the drop down listbox of the License File
property. This listbox shows the list items that are similar to those of the
Readme file. Click on Browse, and then, double click on the Application Folder
that is displayed in the dialog box. Select the file aaa.rtf, which is
displayed here, and click on OK. Once this is achieved, build and install the
project, to gain a sneak preview of the License screen, as shown in 4.69.
|
|
|
Screen 4.69 |
Under normal circumstances, a
valid license agreement, which is drawn up by a lawyer, would have been
displayed. It generally encompasses copyright issues, and availability or
denial of distribution of the software for commercial purposes. Only lawyers
can conjure up the details, and trust me, they get grossly overpaid for it. Two
radio buttons are displayed on the screen, of which, the one containing the
text "I Do Not Agree", is selected by default. The Next button is
grayed out, thereby, preventing the user from proceeding ahead, if he does not
conform to the license. Selecting the radio button containing the text "I
Agree", will enable or activate the Next button. Verify this feature, and
then, cancel the installation, as we are conversant enough with the remaining
dialog boxes that are to follow. This dialog box represents a scenario akin to
a real life situation, wherein, software that is to be installed, displays a
license agreement. The user needs to concur with this agreement, in order to
continue with the installation.
Delete the node, and then, right
click on the Start node. Select the option of 'Add a Dialog', to add the dialog
called the Splash Dialog Box. As is done routinely, we move it to the top
position, and proceed to initialize the few properties that it possesses. Of
the two properties that are displayed, we select the 'Splash Bitmap option',
and as before, choose the Browse option from the Listbox.
We arrive at the familiar
'Select Item in Project' Dialog Box, where we double click on the Application
Folder. Since this folder does not contain any jpg or bmp files, it obviously
is empty.
Akin to the procedure adopted
for the rtf file, we click on Add file, and then, select the bmp file named
"Blue Lace 16.bmp" from the Winnt subdirectory. Click on OK. Then,
build and install the project. The screen that is exposed to view, is shown in
screen 4.70.
|
|
|
Screen 4.70 |
A picture stored in the bmp file
format, gets displayed when the project is installed.
The only downside of this is, the
picture that gets incorporated in the msi file, thereby, increasing the file
size considerably. But still it is worth the overheads, since it makes the user
experience much richer.
Select the Splash node and
delete it. Then, bring-in another dialog called the Radio Buttons (2) dialog
box. Elevate it to the top position, and then, build and install.
|
|
|
Screen 4.71 |
In case you forget to move the
dialog box to the top position, an error message will be displayed, which
notifies that all customized dialogs are to be placed before the Installation
dialog box.
The Radio Buttons enable the
user to choose from amongst a series of mutually exclusive options. Thus, the
user can select only one of the available options, unlike a check box, which
allows multiple options to be selected simultaneously. This property of the
Radio Button can also be used, to conditionally copy certain files. There are
dialog boxes by the dozen, offering a host of radio buttons. As there is no
further utility of the radio button dialog box, we shall dispense with it, with
a flick of the Delete key.
The next in the series of the
dialog boxes that we shall explore is, the TextBoxes (A) dialog box. After
having moved it to the top of the list, build and install the project. The screen that springs up, is shown in
screen 4.72.
|
|
|
Screen 4.72 |
Here, four textboxes are
displayed for the user to fill up. Our installer can figure out what values are
being entered by the users. If we so desire, we may conceal the textboxes, as we
had done in the case of the check boxes.
We now select the textbox node,
and then, delete it with the help of the Delete key. Now, select the Register
User Dialog box and haul it up to the top position, as is generally done.
In the properties window, click
on the Banner Bitmap drop down listbox this time, and select Browse. The Select
Item in Project dialog box shows up. Double click on the Application Folder.
Only the bitmap of "Blue Lace 16.bmp" is displayed. Select it and
click on OK. As usual, build and Install.
The screen 4.73 displays the
selected bitmap at the top of the dialog box. This bitmap comes along with the
installer. Hence, it will not be copied to the Application Folder, i.e. the
folder specified by us, on the target machine.
|
|
|
Screen 4.73 |
To ascertain this, note down the
file size of the .msi file. In our case, it shows 167 KB. Then, reset the
Bitmap property to 'none' and build the project again. The file size reduces to
165 KB. This indubitably proves that the bmp file gets added to the .msi file.
The Register button is disabled.
What is the rationale behind retaining a User Registration dialog box, when the
Register button is disabled?
While the software is being
downloaded from the Internet or is being installed, the Software Company that
developed the software, may want the user to register the product with them.
This process normally is optional, but is used as bait. If a user registers the
product, he will be notified about free upgrades by e-mail. The registration
process is capable of doing numerous other things, but the installer couldn't
care less about them.
The property named Executable has
to be initialized, so as to enable this button. So, select the Browse option,
which would display the Select Item in the project Dialog box. As always, click
on the Application Folder and select Wordpad, since this is the only exe file
that is currently accessible.
Under normal circumstances, the
programmer writes a program, which knows how to register the user information
with the company. That is it! Now click
on OK, and then, build and install. The Register button is alive and kicking!
On clicking this button, Wordpad opens up. This is reflected in screens 4.74
and 4.75.
|
|
|
|
Screen 4.74 |
Screen 4.75 |
If, we click on the Next button,
without quitting out of Wordpad, the installer waits indefinitely. The installer
refuses to proceed any further, until the program concludes. Therefore, exit
from Wordpad and click on the Next button, to proceed to the next screen.
Thereafter, click on the Cancel button, since we lack inclination to advance
any further with the installation.
Let us now focus upon Arguments,
which is the first property of this dialog node. Enter the value of C:\a.txt.
Then, build and install the project. When you click on the Register button,
Wordpad gets executed, with the file a.txt opened in it. Thus, arguments can be
passed to the program, which then exploits the parameters to the optimum. Thus, if we insert the text Wordpad,
followed by a file name as a parameter, it executes, with the file displayed in
it.
Now that we are through with the
Register node, delete it and introduce the Customer Information dialog box.
Move the node to the top. Then, build and install the project. Screen 4.76 now
shows the dialog box with two textboxes; one containing the user name, and the
other including the company name. This is similar to what was entered, while
the Visual Studio.Net was being installed.
|
|
|
Screen 4.76 |
At install time, most products
ask for the name of the user and the company. At times, it also requests the
user to enter a serial number. The screen 4.76 does not show any serial number
at present.
However, if we change the value
assigned to the property ShowSerialNumber to True, the Serial Number Box gets
displayed. Note that the value assigned to the property SerialNumberTemplate,
is as follows: <###-%%%%%%%>. Build the project and install it.
|
|
|
|
Screen 4.77 |
Screen 4.78 |
The serial number box has two boxes,
separated by a hyphen. If we enter the digits 123-4567890, and click on the
Next button, an error message box is displayed, as is visible in screen 4.78.
Unless a valid serial number is entered, the user is denied permission to
proceed any further, thereby, aborting the installation of the software.
In the template, the # symbol
expects a digit. Thus, the 3 # symbols expect the user to enter 3 digits. The %
symbol also represents a digit. Thus, 7 more digits are to be granted next. The
numbers entered in the positions corresponding to the # symbol are ignored.
However, the numbers entered for the positions represented by the % sign, are
added up, and then, divided by 7. Provided that the remainder that is obtained
is zero, the serial number is considered to be valid.
Entering the number 1 seven
times, will result in a remainder of zero. Hence, it is considered to be a
valid serial number. Keep it in mind that the first 3 digits are ignored in the
calculation. Further, the 3-7 combination is not mandatory. You may modify it
to suit your requirement.
Now that we have become familiar
with the Customer node, select it and delete it.
We have garnered adequate
knowledge about customizing the User Interface editor. So, let us now change track
and proceed to the next editor called the Registry. Click on the View menu, and
move the mouse to the Editor menu option.
|
|
|
Screen 4.79 |
The screen that shows up, is
displayed in screen 4.80. Let us spend a little time appreciating and
unraveling the System Registry and the screen displayed below.
|
|
|
Screen 4.80 |
Let us consider a practical
example of Visual Studio.Net, to understand the concept better. Each time we
start the product, we arrive at a start page, which displays the names of the
last four projects that we have worked with. How does Visual Studio.Net
remember the names of these projects? The only likelihood is that, Visual
Studio.Net saves the names of the last four projects on the disk. To be more
precise, it stores it in the Registry.
The Registry is a hidden file,
which stores information in the form of name-value pairs, under different keys
or headings. There must be only one hidden file, which stores relevant information
about various different applications. Consequently, every single application
does not create its own hidden file. This results in optimization of the time
spent on data retrieval. A program called Regedit knows how to display and edit
this file.
Therefore, all programs in our
day, have standardized the procedure of storing all their dynamic data in the
Registry. The keys, along with the name-value pairs, are inserted or modified
in the Registry, during the installation of the product.
As we are in the midst of the
setup and installation process, we are in no position to disregard the Registry
at any cost. So, how do we create a key and add it to the Registry at the time
of installation?
Since the Registry stores a
multitude of name-value pairs, we need to organize them under various headings,
such as, HKEY_CLASSES_ROOT, HKEY_LOCAL_MACHINE, etc. Click on the plus sign of
HKEY_LOCAL_MACHINE. You will see the word Software, with a plus sign below it.
Select Software and right click on it, to view the menu. Select New from the
Menu and then select Key from the popup menu.
|
|
|
Screen 4.81 |
This will result in the creation
of a new key under the Software key, as shown in the screen 4.82.
|
|
|
Screen 4.82 |
Replace the selected text with 'vijay',
and then, view the properties window. There are very few properties displayed
for 'vijay'.
|
|
|
|
Screen 4.83 |
Screen 4.84 |
Right click on 'vijay' in the
Registry editor. The same menu that was displayed while adding the key, is displayed
here. We select the option of 'string value'.
|
|
|
Screen 4.85 |
Once this is done, an entry is made
in the second pane. Enter 'Mukhi' as the new name, and thereafter, assign the
value of 'sonal' to the Value property, in the Properties Window.
|
|
|
|
Screen 4.86 |
Screen 4.87 |
What we have accomplished so
far, is the creation of a key called 'vijay', under the Software key, and have
assigned it a sub-key called 'Mukhi', having a value of 'sonal'.
Using the Start menu (Ctrl+Esc),
run a program called Regedit. The registry displayed by this program, is shown
in screen 4.88.
|
|
|
Screen 4.88 |
Click on the plus sign of HKEY_LOCAL_MACHINE,
and then, click on the plus sign of Software. You may observe that there are no
traces of the key 'vijay' under the key 'Software'.
|
|
|
Screen 4.89 |
Close the registry. Then, build
and install the project completely. Once this is executed, open the Registry
using regedit, and scroll down the list of all the keys under the Software key,
which itself is located under HKEY_LOCAL_MACHINE. You would be delighted to
discover the newly introduced key named 'vijay', nestled comfortably. It has
the name 'Mukhi', with the value of 'sonal' contained in it.
|
|
|
Screen 4.90 |
Thus, with the help of the
procedure outlined above, you can add as many keys as you want, to the Registry.
When you uninstall the project, you will notice that this key also disappears.
Back in the Registry editor, right click on 'vijay' and add a new Key. Name the
key as 'bad'. Screen 4.91 flaunts this
new development.
|
|
|
Screen 4.91 |
Build and install the project
and then, run the Regedit program. In case the Registry is open, you can simply
click on View - Refresh.
|
|
|
Screen 4.92 |
We were totally unaware of the
fact that, adding keys to the Registry could be so straightforward. While
installing any product in real-life, the main key under Software is, the name
of the Company that has created the product. This key contains all the other
keys required by the product. Each application creates hundreds of keys.
Therefore, the Registry grows into a colossal file.
Uninstall the project, so that we can complete our task of exploring the last of the six editors, named Custom Action. As before, click o