Inno Setup全自动安装脚本

  • A+
所属分类:技巧

Inno Setup全自动安装脚本

双击安装程序后,无需进行任何点击操作,只需等待即可自动完成程序的安装,并于安装后自动运行已经安装完的程序。

程序代码如下:

; 脚本由 Inno Setup 脚本向导 生成!
; 有关创建 Inno Setup 脚本文件的详细资料请查阅帮助文档!

#define MyAppName "爱吃鱼的猫内网专用版"
#define MyAppVersion "1.0"
#define MyAppPublisher "爱吃鱼的猫"
#define MyAppURL "https://aichiyudemao.com"
#define MyAppExeName "爱吃鱼的猫内网版.exe"

[Setup]
; 注: AppId的值为单独标识该应用程序。
; 不要为其他安装程序使用相同的AppId值。
; (生成新的GUID,点击 工具|在IDE中生成GUID。)
AppId={{00E13AC2-BB9C-4267-A4BD-CEDC2659578A}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DisableDirPage=yes
DisableProgramGroupPage=yes
DisableWelcomePage=yes
DisableReadyPage=yes
VersionInfoDescription=爱吃鱼的猫登陆器内网版
OutputDir=E:\mofafengyunji\output
OutputBaseFilename=爱吃鱼的猫登陆器内网版
SetupIconFile=E:\mofafengyunji\LoginClient\res\爱吃鱼的猫48x48.ico
Compression=lzma
SolidCompression=yes

[Languages]
Name: "chinesesimp"; MessagesFile: "compiler:Default.isl"

[Code]
const
  WM_LBUTTONDOWN = 513;
  WM_LBUTTONUP = 514;

// 安装前强制杀进
// 该函数在安装程序初始化时调用,返回False 将中断安装,True则继续安装.程
function InitializeSetup(): Boolean;
  var ErrorCode: Integer;
  begin
    ShellExec('open','taskkill.exe','/f /im {#MyAppExeName}','',SW_HIDE,ewNoWait,ErrorCode);
    ShellExec('open','tskill.exe',' {#MyAppName}','',SW_HIDE,ewNoWait,ErrorCode);
    result := True;
  end;

// 卸载前强制杀进程
function InitializeUninstall(): Boolean;
  var ErrorCode: Integer;
  begin
    ShellExec('open','taskkill.exe','/f /im {#MyAppExeName}','',SW_HIDE,ewNoWait,ErrorCode);
    ShellExec('open','tskill.exe',' {#MyAppName}','',SW_HIDE,ewNoWait,ErrorCode);
    result := True;
  end;

procedure InitializeWizard();
begin
  begin
    PostMessage(WizardForm.NextButton.Handle,WM_LBUTTONDOWN,0,0);
    PostMessage(WizardForm.NextButton.Handle,WM_LBUTTONUP,0,0);
  end;
end;

procedure CurPageChanged(CurPageID: Integer);
begin
  if CurPageID = wpSelectProgramGroup then
    WizardForm.NextButton.Caption := SetupMessage(msgButtonInstall)
  else
    WizardForm.NextButton.Caption := SetupMessage(msgButtonNext);
end;
function ShouldSkipPage(PageID: Integer): Boolean;
begin
  result := true;
end;


[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: checkablealone

[Files]
Source: "E:\aichiyudemao\Release\爱吃鱼的猫内网版.exe"; DestDir: "{app}"; Flags: ignoreversion
; 注意: 不要在任何共享系统文件上使用“Flags: ignoreversion”

[Icons]

Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{group}\卸载{#MyAppName}"; Filename: "{uninstallexe}"

[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent


PS:OutputBaseFilename不要与MyAppName相同,否则cmd执行命令时会出现报错。
ico制作可以直接使用本站的转ico工具进行转换生成:转ico工具

百分购

发表评论

您必须才能发表评论!