Use Inno Setup to solve the. Framework framework installation problem

Source: Internet
Author: User
Tags java se

Some time ago, a friend took over a project, specifically developing a software installed in the LAN, which will regularly connect to the server in the LAN to update some information about the local client, because there are a variety of different Windows versions in the LAN, from WindowsXP, Windows2003 and windows2008 to windows7, this software uses vs2008 /. net framework2.0 development, because some systems are not installed by default. net framework2.0, so you must ensure that the client has been installed. net framework2.0, so I thought of packaging the software.

There are several tools and solutions for creating the software installation package: one is to use the installation package that comes with Visual Studio; the other is to use InstallShield, a paid and professional installation package creation tool; third, use the free and professional installation package creation tools such as Inno Setup.

I did not have a deep research on the installation package tools provided by Visual Studio. In the early days, I tried to package the software into an installation file, but eventually failed. Then I simply stopped studying it; installShield and other paid installation packages have powerful software functions, but it is not easy to get started. In addition, they are charged. (Although you can find a cracked version, you always feel uncomfortable ), so I sought to use Inno Setup to solve the problem.

Inno Setup is a free installation software for windows. It supports all currently used Windows versions: 7, 2008 R2, Vista, XP, 2008,200 3, 2000, me, 98, 95, and NT 4.0 (no service package is required ). Inno Setup was first introduced in 1997 and is a free open-source software, even for commercial use. Inno Setup official website is http://www.jrsoftware.org, of course you can also download its Chinese version, such as [Fenglin night thinking rain] hanhua Inno Setup is not bad, I used the English version of the Inno Setup File when packaging for a friend, but it was used in the installation file. I have translated the isl file into Chinese.

The method we came up with was to make the software into an installation package. when running the installation package, we checked whether the software was installed on the client. net framework2.0. If not, download it from the server in the LAN. net framework2.0 installation file, and then continue to install and configure the developed software.

The code for this solution is as follows:

 

 

[Code] <br/> function initializesetup: Boolean; <br/> var path: string; <br/> resultcode: integer; <br/> begin <br/> If regkeyexists (HKLM, 'Software/Microsoft /. netframework/policy/V2.0 ') Then <br/> begin <br/> result: = true; <br/> end <br/> else <br/> begin <br/> If msgbox ('the system has detected that you have not installed it. net framework2.0. Do you want to download and install it immediately? ', Mbconfirmation, mb_yesno) = idyes then <br/> begin <br/> path: = expandconstant (' {pf}/Internet Explorer/iexplore.exe '); <br/> exec (path, 'HTTP: // www.xxx.com/down/dotnetfx2.exe', '', sw_shownormal, ewwaituntilterminated, resultcode); <br/> msgbox ('Please install it. and then run the installation package! ', Mbinformation, mb_ OK); <br/> result: = false; <br/> end <br/> else <br/> begin <br/> msgbox ('not installed. net framework2.0 environment, unable to run XXX program, this installer is about to exit! ', Mbinformation, mb_ OK); <br/> result: = false; <br/> end;

The above code checks the registry to determine whether. Net framework2.0 is installed on the client. If not, download it from http://www.xxx.com/down/dotnetfx2.exe, and prompt the user to install the downloaded. Net framework2.0 program and then install the program. This has an advantage because not all machines are installed. net framework2.0. Therefore, only some uninstalled machines need to be downloaded. net framework2.0 is packaged into the installation package, which is a relatively small installation package.

However, in some cases, problems may occur. For example, if a good software is developed, the user can access the Internet and download and install the software in the office, it is difficult to install and use a copy on a machine that has no Internet access at home. Therefore, the following is another solution. net framework2.0 is packaged into the installation file, and check whether the client is installed before the installation starts. net framework2.0.. Net framework2.0 Installation File is extracted from the installation package to the Temporary Folder and installed from the Temporary Folder. Otherwise, the developed software is directly installed, files in the Temporary Folder will be automatically cleared when the system restarts, so you do not have to worry about occupying disk space.

The following are some key code:

[Files] ...... source: "F:/Zhou Gong's column/dotnetfx20.exe"; destdir: "{TMP}"; flags: ignoreversion; Zhou Gong's column tips: dotnetfx20.exe is not copied to the installed directory, but in the temporary directory. After the machine is restarted, the [Code] function checkdotnet2_0 (): Boolean; beginresult: = Not regkeyexists (HKLM, 'Software/Microsoft /. netframework/policy/V2.0 '); end; function initializesetup (): Boolean; var path: string; resultcode: integer; begin if checkdotnet2_0 () then begin extracttemporaryfile('dotnetfx20.exe '); exec (expandconstant ('{TMP}/dotnetfx20.exe'), '','', sw_shownormal, ewwaituntilterminated, resultcode); end; Result: = true; end;

After passing through the code, it is guaranteed that dotnetfx20.exe will not be copied to the installed folder. in Visual Studio and InstallShield, I believe this function should also be available, but I did not find it. I think this function is more practical, if your machine has been installed. net framework2.0will not be merged during installation. Otherwise, dotnetfx20.exe will be released to the Temporary Folder and installed in the Temporary Folder. net framework2.0. This ensures that dotnetfx20.exe does not occupy the space of the installation folder. . There is no way to do this, for example, Java that can span * nix and Windows earlier and Java that can now be different versions. net, in order to achieve the same performance on different platforms, it is necessary to support the runtime, the so-called bear's paw fish cannot have both, although some third-party software can be developed by Java or. the software on the net platform is made into an EXE file that does not require runtime support, but whether it can achieve consistent performance on each platform remains to be verified.

In fact, this method can not only be used for detection. net framework2.0 can also be used in other cases, such as detection. net framework3.0 or. net framework3.5, especially when you show your friends your developed WPF applications. It can also be used to deploy Java SE projects.

 

Zhou Gong

February 28, 2010

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.