首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用Inno Setup进行静默安装?

如何使用Inno Setup进行静默安装?
EN

Stack Overflow用户
提问于 2014-02-05 18:56:36
回答 1查看 17.9K关注 0票数 12

在安装向导过程中,我需要在没有下一步按钮的情况下为我的应用程序启动静默安装。请任何人帮帮我。

EN

回答 1

Stack Overflow用户

发布于 2014-02-05 20:32:02

在静默模式下运行安装程序的正确方法是,始终使用/SILENT命令行参数执行它。例如,这样做:

代码语言:javascript
复制
setup.exe /SILENT

在我们在注释中澄清了您的要求后,我看到您实际上想要构建一个安装程序,它将在没有提到的命令行参数的情况下以静默模式运行。目前,没有内置的方法来告诉编译器您想要构建静默安装程序,所以我们需要在初始化安装程序时使用/SILENT命令行参数重新运行安装程序来解决这个问题。

以下脚本显示了此解决方法:

代码语言:javascript
复制
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program

[Code]
#ifdef UNICODE
  #define AW "W"
#else
  #define AW "A"
#endif
type
  HINSTANCE = THandle;

function ShellExecute(hwnd: HWND; lpOperation: string; lpFile: string;
  lpParameters: string; lpDirectory: string; nShowCmd: Integer): HINSTANCE;
  external 'ShellExecute{#AW}@shell32.dll stdcall';

function InitializeSetup: Boolean;
begin
  // if this instance of the setup is not silent which is by running
  // setup binary without /SILENT parameter, stop the initialization
  Result := WizardSilent;
  // if this instance is not silent, then...
  if not Result then
  begin
    // re-run the setup with /SILENT parameter; because executing of
    // the setup loader is not possible with ShellExec function, we
    // need to use a WinAPI workaround
    if ShellExecute(0, '', ExpandConstant('{srcexe}'), '/SILENT', '',
      SW_SHOW) <= 32
    then
      // if re-running this setup to silent mode failed, let's allow
      // this non-silent setup to be run
      Result := True;
  end;
end;
票数 22
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21575241

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档