InstallShield Installation __installshield

Source: Internet
Author: User
Tags advantage

Objective

InstallShield can be said to be one of the best business software to do the installer, but because the function is so powerful that it is not easy to get started and proficient, before using InstallShield Project assistant to deal with the past, This time to do this installation program, in order to achieve some functions, must write code, domestic and foreign ready-made information is very small, and a lot of vague, oneself repeatedly chewed several times, contrast Installshiel with help, just understand the meaning of the information. Although this installation program is relatively simple, in the eye of experts may be a piece of cake, but also spent the author one weeks of time, read a lot of information, chewed for several days in English help, integrated a lot of pioneers experience, but also cost a lot of their own painstaking work, the use of each piece of code, Every function used is described in detail, so please be sure to keep the reproduced source and the words produced by the sea goddess of Azeroth, if you want to publish, please contact the author.

Here to thank the Piggy Swallow coins, the world Xiao Ming, Yu Manqing, ocean C + + paradise (This ocean is not the ocean) and other prawns in the Internet selfless dedication, their posts and blogs gave me great inspiration.

Because I do Java origin, so this class C + + language is the first contact, there is no understanding of the place, please friends to correct me. Welcome email to Little_fairycat@126.com

Body

Requirements: The company has made a software product,

1. This software operation requires JDK environment (not JRE, because the software is to register a service to Windows, the use of JAVASERVICE,JDK to support this function; However, it focuses on whether or not a software installation is installed, rather than obsessing over the installed JDK or the JRE);

2. Because it is server-client form, it is necessary to allow users to choose the installation components, such as a machine only installed server, B machine only installed client end;

3. Document is not packaged in the installer, directly stored in the CD folder for users to view, while allowing users to specify whether to install the document to the computer (why do this, followed by the detailed reasons);

4. The software will be issued to the user in the form of authorization, different users, the software itself may be the same, but only different authorization files and some configuration, so that the authorization files and configuration files are not packaged in the installer, and directly stored in the CD, to reduce the possibility of duplication of the installation process of labor;

5. After installation, want to be able to start the program (because the software needs to be installed after the installation of a program, the program to register the service to the Windows function, the program is best started by the installation program, rather than by the customer manually start).

6. Want to have an anti-Setup program

The "external" referred to in this article refers to folders that are not packaged in the installer and that are stored in the CD with the installer, which contains the files required for installation and may have other uses, and is therefore not suitable for direct compression and packaging in the installer.

This example implements the following functions:

1. Display Software License Agreement

2. Determine whether the software required to install the prerequisite software jkd1.6.0_04, if not, then start the external installation program to install (the same principle can be used to determine whether the installation of other software, as long as the software in the registry has a key value)

3. Installation allows the user to select the components that need to be installed

4. The user's input information, the selected installation path, and the selected installation component will be displayed in the installation interface (InstallShield, although it has this interface, is displayed as null by default and requires a script to display the information)

5. According to the user selected components, in the Start menu to display the program shortcuts (also applies to desktop shortcuts, after the detailed instructions)

6. According to the components selected by the user, copy the corresponding files from the external folder to the folder of the installation target path

7. Create shortcuts based on files that are copied from the outside (mainly copying documents and creating shortcuts in the Start menu)

8. Display the Readme.txt file at the end of the installation

9. At the end of the installation, start the specified program

10. Perfect Uninstall

The environment for the author is InstallShield Premier edition,windows XP with SP2, which can be used directly under InstallShield 2008 Premier. InstallShield 2008 in opening InstallShield 12 of the project will be prompted if you need to upgrade, confirm, the software will automatically upgrade for you, very convenient.

Let's build a basic project step-by-step, and use the script to refine and enrich the required functionality


The first part: basic settings

1. Open InstallShield Premier Edition and create a new InstallScript MSI Project called a half-script program because it has both basic Project base types and Installscrip T project full script type the advantages of both are I prefer to use. such as I need, not only to use the Convenience of wizard, but also want to write a little script to achieve a bit of custom operations, it is more appropriate to use this type.

Select Type is Windows Installer | InstallScript MSI Projcet, enter the project name and specify the folder in which the project is located.

2. The interface will switch to Project Assistant, where we start by building the basic components and basic files of the project.

3. At the bottom of the Project assistant interface, there will be a guided action bar, which we will operate on when the basic structure and files of the project are established, and the following will be referred to as "guide bar" for this boot action bar.

4. Click on the application information on the guide bar

Here Enter:

Company name, company names will appear in Setup.exe's notes

The name of the software that will appear on the title bar in the upper-left corner of the installation process

Version number, did not see where, but it is easier for you to know what version of the software you are compiling

Company web site, did not see where, and if the company does not have a Web site. And here is a bit of a bug, as if the default value will always report a STRING_ID1 error, the input of a Web site will not error.

Whether to automatically notify the end user when you create an update, I have chosen No.

Select an icon, this icon will appear in the "Add or Remove Programs", I generally use the default, of course, you can replace the icon you want.

5. Click on the installation requirement on the guide bar

Here you choose the requirements for the operating system and some software. Depending on your needs, select whether the operating system version is required, and whether certain software has been installed.

6. Click on the installation architecture on the guide bar

This is a very useful setting, suitable for the distributed software used in this article, where each component of the distributed software can be set to a feature, and the user is free to choose to install certain features.

Select want to customize your installation option to Yes.

Click to select the root node installation architecture, click New to create a new feature, you can specify a new name for each feature.

You can also create Child feature under feature, for example, if the document feature contains documentation for the software itself, and for the running environment that the software requires, you can create two child feature, each containing two documents, and the user can choose to install some or all of the documents at the time of installation. Here we do not use the feature, the use of the same as ordinary feature.

Here, after setting up all the feature, we'll switch to installation designer do a setup

Locate the Installation Designer page on the left navigation tree Organization | Features branch, you will see here the features are displayed as the original name, not the name we changed because feature has the name and display names two, and we just changed the display name to make it easier to view and use. We'll change the name here, too.

Note Name can not have spaces, you can use underscores

Continue switching back to project Assistant

7. Click on the application Files on the guide bar

We will fine-tune the installation path here and specify the files that need to be installed for each feature

I don't want to use program Files here | Company Name | Product name This path, I want to use program Files | Product name, I click to select My product Name[installdir] to drag to Programfilefolder, and I can change my product name to the folder name I want directly

Next, specify the files to be installed for each feature.

Open this Drop-down list, all the feature are here, in order to create a folder for each feature, and import the required files.

Select the first feature, the server, click the My Product Name[installdir] node, right-click, and select New folder on the menu to create one.

Create a server folder that will be used to store some of the files that the component needs.

Then create an icon folder under the server folder to store the icons used for the component.

The feature is then added to the file that the feature will install when it is installed.

The icon folder we created here is used to store the icons used by this feature to create a shortcut later. Add the icon file for this icon folder and remember the source folder for the icon file and use it when you set the shortcut.

Click to select the folder where you want to add the file, then click Add Files in the lower right corner and add the file

Next we add a folder for feature, if all the files in this folder are required for this feature. The advantage of adding a folder is that as long as the folder location and name are unchanged, the files inside the folder are dynamically loaded and how much is loaded, regardless of the impact of the file name changes.

Click to select the folder where you want to add the folder, and then click Add Folders in the lower-right corner and add the folder.

Select the folder and click OK.

Will ask you whether you want to use dynamic file links, I have chosen to determine, the advantage is that I have just described above.

Displays the source folder, and if you have subfolders under this folder and you need to add them together, be sure to hook the Include subfolders option.

It also allows you to make some simple settings to include or exclude certain files, and to support wildcard characters.

Click OK to make sure to join the folder.

The following example creates a folder for each feature and adds the file, and the final effect is shown in the figure

Document This feature, in addition to the icon used in the file, do not add anything, later we will use the installation of real-time copy of the documents in the way to come in.

8. Next we create a shortcut for the executable file.

Click on the application shortcuts on the guide bar

Click New to create a new shortcut

Select a feature to set up a shortcut.

If the program you want to create a shortcut for is a non-. exe form, select the files of choice as the All Files (*.*) format.

Our program installation target path is set under Programs files, so double click [ProgramFilesFolder] to open, layer by click to enter.

We're going to create a shortcut for Client.bat because this is the batch file that starts with.

InstallShield can automatically monitor the presence of. exe files, automatically generate shortcuts, users need to do some appropriate modification.

The new shortcut will appear here, the name is not good, look bad, we will change a name for it, and change an icon.

Select the shortcut, click Rename, and change the appropriate name for the shortcut.

Notice several options on the right.

The Create shortcut in Start menu, which creates a shortcut in the Start menus.

Create shortcut on Desktop, a shortcut is created on the desktop.

Use alternate shortcut icon to replace the shortcut icons

Associate a file extension with the shortcut ' target, no use, don't know what it means.

We will only create a shortcut to the Start menu here, so the first item is hooked.

Select the third item and click Browse to browse the icon.

Recall that when you added a file for feature, each feature added a corresponding icon. Here, please set the Browsing folder for just add icons folder, popular say, is where you just add an icon into the feature, now or from where to add this icon.

In fact, I have been very puzzling, at the outset did not know to choose this icon, casually from a random outside folder to add an icon, so that after packing dead and dead can not find the icon, and then after the test to know that the selected icon file to copy in, packaged into the installation file can be. This point is not to mention Visual Studio, this tool to do the installer although the function of general, but the idea is good, when its components specify the copy icon file, when the shortcut is established, the shortcut used icon to point to the virtual installation target path under the icon file, Instead of assigning to this real source folder. This difference is a reflection of the ideological differences.

This is the same as specifying a shortcut for each feature, except for document, because we have not added anything except the icon file in this feature.

So we've added a shortcut to the Start menu for each executable program.

We'll switch to installation Designer and find System Configuration | Shortcuts.

See the shortcut in the Start menu is based on the company name | software name | Shortcut this form exists. In fact, I do not like this form, think about the point open a layer and a layer, as direct when come simply, so make some changes.

Here I changed to the following settings

Don't tell me you're not going to change. Drag the test folder to the next plug in Program menu (that is, "All Programs" under the Start menu), and then remove the extra company name folder.

9. May have just been in the Project assistant interface has been noticed in the left column more options under the Create an uninstallation shortcut this seductive words.

But I'm telling you, if you choose this way to build uninstall shortcuts, you'll be frustrated to find:

A It appears that the uninstall shortcut will only appear when a feature is installed (and, of course, that default feature, this deadly feature form determines that each file or shortcut must be explicitly assigned to a feature), When your client selects only other feature installations, the uninstall method does not appear, and he must go to the "Add or Uninstall program" to uninstall

b If you write a script that makes the installation copy some of the external files in, the files will not be removed under this uninstall method. (If you do want to save these files, you can set their properties to permanent in the script, which will ensure that none of the uninstall methods can delete your files).

So here we are ignoring the existence of this uninstall shortcut, which will be followed by a scripted implementation of the perfect uninstall.

10. Click on the application Registry on the guide bar

Write key and key values to the registry, as this project is not required, ignore it. Friends who need to have access to the relevant information, not difficult.

11. Click on the installation Location on the guide bar

This is used to set the language of the installation package, after selecting multiple languages, the user can choose the language to install at the beginning of the installation interface; But as a company product, so lazy, customer impression is to discount, so choose a single Language bar, what language installation package on what language installation package, Each individual.

However, you will be frustrated to find that if you want to choose a different language as the default Language, it seems that the error.

This question at that time has been tossing me one weeks (of course then only contact InstallShield, also ignorant), finally asked the technical support to solve.

Switch to installation Designer, find installation Information | General information, see what's underneath string tables. Yes, all the languages you choose are listed, select the language you want, right-click, choose Make Default,ok, and then switch back to project Assistant to remove all the words that you don't want.

See here, has become Chinese as the default language.

12. Click on the build installation on the Guide bar.

Packaging installation disk settings, I never use this option, are using the release Wizard on the toolbar.

At this point, the first part of the basic completion. If there are no special requirements for the installation package, this section will be enough to do a basic installation package

Part Two: script programming

Before we start programming, let's be clear about what we need to do to make up for the previous set of features.

1. Display Software License Agreement

2. Determine whether the software required to install the prerequisite software jkd1.6.0_04, if not, then start the external installation program to install (the same principle can be used to determine whether the installation of other software, as long as the software in the registry has a key value)

3. The user's input information, the selected installation path, and the selected installation component will be displayed in the installation interface (InstallShield, although it has this interface, is displayed as null by default and requires a script to display the information)

4. According to the components selected by the user, copy the corresponding files from the external folder to the folder of the installation target path

5. Create shortcuts based on files that are copied from the outside (mainly copying documents and creating shortcuts in the Start menu)

6. Display the Readme.txt file at the end of the installation

7. At the end of the installation, start the specified program

8. Perfect Uninstall

This part of scripting is going to be in the Installer designer interface. Don't repeat it later.

InstallShield is sensitive to case sensitivity, so follow the case rules written on the example Strictly. Example: String variable strings and string are supported, but string is not supported.
1. Display Software License Agreement

1. Add License Agreement text

Find behavior and Logic on the left navigation tree | Support files/billboards option. This option allows the user to add some files that need to be used during the installation process.

The middle navigation bar displays the corresponding options

Under the Support Files branch, a language independent and all the types of languages you choose will be displayed. Language independent meant to be, if you make a setting here, this setting takes effect regardless of the language you choose to install, and each language type means that if you set it in a language, the setting will only take effect if you choose to install it in that language.

Click Language Independent, this time we will experiment under this branch.

Right-click in the files bar on the right and choose Insert Files on the pop-up menu.

Select the text file for the previously written license agreement and insert it into the files bar.

The license agreement allows two text formats: TXT and RTF, where we use the TXT format.

2. Then switch to behavior and Logic | InstallScript option,

3. In the middle of the navigation bar files have a default Rul file Setup.rul, all of our project InstallScript code will be written in this default file

4. Click to select the Setup.rul node, the right side will display the file's programmable panel.

5. The license agreement should be displayed at the start of running the installer, i.e. before copying the data. Please select the Before move Data option in the first Drop-down box. Then in the Second Drop-down box, select the Onbegin option (not because the default display of these two options, and do not do this to open the Drop-down list to select the action, otherwise the software does not detect you chose the option, can not automatically add code), The programming interface will automatically add some code as shown in the following illustration. Of course, it's OK if you knock the code up manually.

6. We will write code in function Onbegin () to display the contents of the license agreement text just added, and copy the following code directly to the begin and end of the Onbegin () function.

Disable (Backbutton);

if (! maintenance) Then

SdLicense2 ("License", "", "" ", Supportdir ^" 2.txt ", FALSE);

endif;.

7. Code Interpretation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.