; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "MyTest"
#define MyAppVersion "1.0"
#define MyAppPublisher "MyCompany"
#define MyAppURL "https://www.example.com/"
#define MyAppExeName "WpfApp6.exe"
#define MyAppAssocName MyAppName + " File"
#define MyAppAssocExt ".myp"
#define MyAppAssocKey StringChange(MyAppAssocName, " ", "") + MyAppAssocExt
[Setup]
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{EED5BAF5-C082-417A-948F-83E358749364}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={autopf}\{#MyAppName}
ChangesAssociations=yes
DefaultGroupName={#MyAppName}
; Uncomment the following line to run in non administrative install mode (install for current user only.)
;PrivilegesRequired=lowest
OutputDir=C:\Users\Administration\Desktop\Debug
OutputBaseFilename=MyTest
SetupIconFile=C:\Users\Administration\Desktop\facvtion.ico
Compression=lzma
SolidCompression=yes
WizardStyle=modern
[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:='https://dotnet.microsoft.com/zh-cn/download/dotnet-framework/net472';
dotNetV2PackFile:='{src}\net4.7.2.exe';
//先在注册表查找.net4.0是否存在
if RegKeyExists(HKLM, dotNetV2RegPath) then
begin
Result := true;
end
//如果注册表里面没有发现.net4.7.2
else
begin
if MsgBox('The system has detected that you do not have the. Net framework 4.7 running environment installed. Do you want to install it now?', mbConfirmation, MB_YESNO) = idYes then
begin
//和setup同级目录下的donet安装包
Path := ExpandConstant(dotNetV2PackFile);
//先抽取到临时目录
tmppath := ExpandConstant('{tmp}\net4.7.2.exe');
ExtractTemporaryFile('net4.7.2.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 install. Net framework 4.7.2 running environment successfully, the system will not be able to run, this installation program will exit soon!',mbInformation,MB_OK);
end
end
else
begin
if MsgBox('There is no. Net framework 4.7.2 installation program in the software installation directory. Do you want to download and install now?', mbConfirmation, MB_YESNO) = idYes then
begin
Path := ExpandConstant('{pf}/Internet Explorer/iexplore.exe');
Exec(Path, dotNetV2DownUrl , '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);
MsgBox('Please install the. Net framework 4.7.2 environment before running this installation package!',mbInformation,MB_OK);
Result := false;
end
else
begin
MsgBox('If you do not download and install the. Net framework 4.7.2 running environment, the system will not be able to run. This installation program will exit soon!',mbInformation,MB_OK);
Result := false;
end
end
end
else
begin
MsgBox('If the. Net framework 4.7.2 running environment is not installed, the system will not be able to run. This installation program will exit soon!',mbInformation,MB_OK);
Result := false;
end;
end;
end;
[Languages]
Name: "chinesesimplified"; MessagesFile: "compiler:Languages\ChineseSimplified.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Files]
Source: "C:\Users\Administration\Desktop\WpfApp6\bin\Debug\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Registry]
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocExt}\OpenWithProgids"; ValueType: string; ValueName: "{#MyAppAssocKey}"; ValueData: ""; Flags: uninsdeletevalue
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}"; ValueType: string; ValueName: ""; ValueData: "{#MyAppAssocName}"; Flags: uninsdeletekey
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\{#MyAppExeName},0"
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\{#MyAppExeName}"" ""%1"""
Root: HKA; Subkey: "Software\Classes\Applications\{#MyAppExeName}\SupportedTypes"; ValueType: string; ValueName: ".myp"; ValueData: ""
[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent