Inno Setup setup [supports Silent Installation of the. NET environment]

Source: Internet
Author: User

1. paste source code

The script is generated by the Inno Setup script wizard!
For more information about creating an Inno Setup script file, see the help documentation!

# Define myappname "testset"
# Define myappversion "1.0"
# Define myapppublisher "zcf"
# Define myappurl "http://www.zcfsky.com /"
# Define myappexename "testapp.exe"

[Setup]
Note: The appid value identifies the application separately.
Do not use the same appid value for other installers.
; (Generate a new guid, click the tool | generate a guid in IDE .)
Appid = {A7293410-B577-4984-939A-4969DC799A5C}
Appname = {# myappname}
Appversion = {# myappversion}
Apppublisher ={# myapppublisher}
Apppublisherurl ={# myappurl}
Appsupporturl = {# myappurl}
Appupdatesurl = {# myappurl}
Defaultdirname = {pf}/{# myappname}/Test Program/
Usepreviusappdir = Yes
Defaultgroupname = testapp
Allownoicons = Yes
Outputbasefilename = setup
Setupiconfile = D:/installer/testapp/book. ICO
Compression = lzma
Solidcompression = Yes

: Administrator privilege
Privilegesrequired = Admin

[Ages]
Name: "chinesesimp"; messagesfile: "compiler: Default. isl"

[Tasks]
Name: "desktopicon"; Description: "{CM: create‑topicon}"; groupdescription: "{CM: additionalicons}"; onlybelowversion: 0, 6.1
Name: "quicklaunchicon"; Description: "{CM: createquicklaunchicon}"; groupdescription: "{CM: additionalicons}"; flags: unchecked

[Files]
Source: "D:/installer/testapp/testapp.exe"; destdir: "{app}"; flags: ignoreversion
Source: "D:/installer/testapp/testapp.exe. config"; destdir: "{app}"; flags: ignoreversion
Source: "D:/installer/testapp/readme.txt"; destdir: "{app}"; flags: ignoreversion
Source: "D:/installer/testapp/include/dotnetfx.exe"; destdir: "{TMP}"; check: isneedinstall; copymode: onlyifdoesntexist; flags: ignoreversion deleteafterinstall
Note: Do not use "Flags: ignoreversion" on any shared system files"

[Icons]
Name: "{group}/{# myappname}"; filename: "{app}/{# myappexename }"
Name: "{group}/view the file"; filename: "{app}/readme.txt"
Name: "{group}/{CM: uninstallprogram, {# myappname}"; filename: "{uninstallexe }"
Name: "{commondesktop}/{# myappname}"; filename: "{app}/{# myappexename}"; tasks: Too topicon;
Name: "{userappdata}/Microsoft/Internet Explorer/quick launch/{# myappname}"; filename: "{app}/{# myappexename}"; tasks: quicklaunchicon

[Code]
VaR
Isneeddf: Boolean;
Function isneedinstall (): Boolean;
Begin
Isneeddf: = true;
If (regkeyexists (HKLM, 'Software/Microsoft/. netframework/policy/V2.0 ') then
Begin
Isneeddf: = false;
Result: = false;
End
Else
Result: = true;
End;

Procedure curstepchanged (curstep: tsetupstep );
VaR
PT: string;
Resultcode: integer;
Begin
If (curstep = sspostinstall) then
Begin
If isneeddf then
Begin
PT: = expandconstant ('{TMP}/dotnetfx.exe ');
If (fileexists (PT) then
Begin
If (not exec (PT, '/Q: A/C: "install.exe/qb"', '', sw_hide, ewwaituntilterminated, resultcode) then
Begin
Msgbox ('. Net Running Environment Installation failed, please install it manually! ', Mbinformation, mb_ OK );
End;
End
Else
Begin
Msgbox ('file not found '+ Pt, mbinformation, mb_ OK );
End;
End
Else
Msgbox (You neednt install. NET Framework 2.0 ', mbinformation, mb_ OK );
End;
End;

[Messages]
Beveledlabel = cosail Software Co, Ltd.

[Run]
Filename: "{app}/{# myappexename}"; Description: "{CM: launchprogram, {# stringchange (myappname ,"&","&&")}}"; flags: unchecked Nowait postinstall skipifsilent

2. Explanation of key locations

[Tasks] The code segment flags: unchecked is selected by default.
[Files] Adding Check: isneedinstall in the code segment is a judgment to check whether the code is processed. isneedinstall is a function customized in the [Code] code segment.

[Run] After the code snippet flags is installed with an unchecked, this option is not checked. This option is not selected by default.

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.