satheesh
satheesh

Reputation: 183

How to make the installation always run silently?

I need to start the silent installation for my application without Next buttons in the installation wizard process. Please any one help me.

enter image description here

Upvotes: 13

Views: 29646

Answers (2)

Tung Truong Quang
Tung Truong Quang

Reputation: 1

Using @TLama trick, you can compress two files to one file using iexpress:

  • setup.bat: setup.exe /SILENT
  • setup.exe

Upvotes: -2

TLama
TLama

Reputation: 76693

Proper way to run the setup in silent mode is, and always be executing it with /SILENT command line parameter. 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.

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;

Upvotes: 26

Related Questions