Innosetup automatically detects and installs the. Net Framework

Source: Internet
Author: User

Innosetup can insert the [code] snippet in the script, where the code can be event-driven and the main events supported are as follows:

function Initializesetup (): Boolean; --Setup initialization, the return value determines whether the installer continues execution.
function Nextbuttonclick (Curpageid:integer): Boolean; --click the Next button, and the return value determines whether the installer continues execution.
function Backbuttonclick (Curpageid:integer): Boolean; --Click the Back button and the return value determines whether the installer will continue to execute.
function Initializeuninstall (): Boolean; --Uninstaller initialization, the return value determines whether the uninstaller continues execution.
...
From these events we can see that initializesetup () meets our requirements, and we can check the registry or system files at this time to determine if the. Net Framework is installed on the client machine for automatic installation or download of the installation.

[Code]function Initializesetup:boolean;           var path,tmppath:string;    Resultcode:integer;      dotnetv2regpath:string;     dotnetv2downurl:string; dotnetv2packfile:string; Begin Dotnetv2regpath:= ' software\microsoft\.  Netframework\policy\v4.0 ';   dotnetv2downurl:= ' http://dl1sw.baidu.com/soft/9b/15910/Microsoft.NET.exe?version=585709662 ';    dotnetv2packfile:= ' {src}\dotnetfx40_full_x86_x64.exe ';   Look in the registry first. Net4.0 whether there is an if regkeyexists (HKLM, Dotnetv2regpath) THEN BEGIN Result: = true; End//If not found in the registry. net4.0 else BEGIN if MsgBox (' system detects that you are not installing the. Net Framework4.0 running environment, is it installed now? ', mbconfirmation, mb_yesno) = Idyes THEN BEGIN//and the Donet installation package in the Setup peer directory Path: = Expandconstant (Dotn          Etv2packfile);          First extract to temp directory Tmppath: = Expandconstant (' {tmp}\dotnetfx40_full_x86_x64.exe ');          Extracttemporaryfile (' Dotnetfx40_full_x86_x64.exe ');          MsgBox (Tmppath, mbconfirmation, Mb_yesno); Exec (Tmppath, ",", Sw_shOwnormal, ewwaituntilterminated, ResultCode);  if (fileordirexists (tmppath)) THEN begin Exec (Tmppath, '/q ', ' ', SW_SHOWNORMAL, ewwaituntilterminated,          ResultCode);          If Regkeyexists (HKLM, Dotnetv2regpath) THEN BEGIN Result: = true; End ELSE begin MsgBox (' failed to successfully install the. Net Framework4.0 running environment, the system will not run, this installer is about to exit!         ', MBINFORMATION,MB_OK); End end ELSE BEGIN if MsgBox (' Software installation directory does not contain a. Net Framework4.0 installer, are you ready to download and install now? ', mbconfirmation, mb_yesno) = Idyes THEN begin Path: = Expandconstant (' {pf}/internet explo          Rer/iexplore.exe ');          Exec (Path, Dotnetv2downurl, ", SW_SHOWNORMAL, ewwaituntilterminated, ResultCode); MsgBox (' Please install the. Net Framework4.0 Environment, then run this installation package!           ', MBINFORMATION,MB_OK);         Result: = false; End ELSE begin MsgBox (' install. Net Framework4.0 running environment, the system will not run, this installer is about to exit! ', MBINFORMATION,MB_OK);         Result: = false; End END end ELSE begin MsgBox (' No. Net Framework2.0 running environment is installed and the system will not run, this installer Coming out!       ', MBINFORMATION,MB_OK);        Result: = false;  End End;end;

Reference link 1:http://blog.csdn.net/hualei/article/details/2628312

Reference link 2:http://zhoufoxcn.blog.51cto.com/792419/279243/

Innosetup automatically detects and installs the. Net Framework

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.