简体   繁体   English

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

[英]How to make the silent installation by using Inno Setup?

I need to start the silent installation for my application without Next buttons in the installation wizard process.我需要在没有安装向导过程中的下一步按钮的情况下为我的应用程序启动静默安装。 Please any one help me.请任何人帮助我。

在此处输入图片说明

Proper way to run the setup in silent mode is, and always be executing it with /SILENT command line parameter.在静默模式下运行安装程序的正确方法是,并且始终使用/SILENT命令行参数执行它。 For instance this way:例如这种方式:

setup.exe /SILENT

After we clarified your requirement in comments I see, that you actually want to build a setup, which will run in silent mode without the mentioned command line parameter.在我们在评论中澄清您的要求后,我看到您实际上想要构建一个设置,该设置将在没有提到的命令行参数的情况下以静默模式运行。 Currently, there's no built-in way to tell the compiler, that you want to build a silent setup, so we need to workaround this by re-running the setup with the /SILENT command line parameter when the setup is being initialized.目前,没有内置方法告诉编译器您要构建静默设置,因此我们需要通过在初始化设置时使用/SILENT命令行参数重新运行设置来解决此问题。

The following script shows this workaround:以下脚本显示了此解决方法:

[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;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM