View Single Post
  #18  
Old 05-03-2018, 07:58
vint56 vint56 is offline
Registered User
 
Join Date: May 2011
Location: almaty
Posts: 52
Thanks: 145
Thanked 55 Times in 31 Posts
vint56 is on a distinguished road
jitender
Code:
[Setup]
AppName=My Application
AppVersion=1.5
DefaultDirName={code:GetInstallDir|{pf}\My Application}
DisableProgramGroupPage=yes
Uninstallable=not PortableCheck
OutputDir=.

[Files]
Source: "MyProg - installer.exe"; DestDir: "{app}"; Flags: ignoreversion; Check: InstallerCheck;
Source: "MyProg - portable.exe"; DestDir: "{app}"; Flags: ignoreversion; Check: PortableCheck;

[Icons]
Name: "{commondesktop}\My Application"; Filename: "{app}\MyProg - installer.exe"; Check: InstallerCheck;

This is CODE section add [] +Code
var
  Portable,Installer: TNewRadioButton;

function CheckParam(s: string): boolean;
var
  i: integer;
begin
for i := 0 to ParamCount do begin
  Result := ParamStr(i) = s;
if Result then Break;
end;
end;

function GetInstallDir(S: String): String;
begin
  if CheckParam('/P') then
    Result:= ExpandConstant('{userdesktop}\My Application Portable')
  else
    Result:= ExpandConstant(S);
end;

function PortableCheck: Boolean;
begin
  Result := Portable.Checked or CheckParam('/P');
end;

function InstallerCheck: Boolean;
begin
  Result := Installer.Checked or CheckParam('/I');
end;

procedure InitializeWizard();
begin
  WizardForm.DirEdit.Text:= ExpandConstant('{code:GetInstallDir|{pf}\My Application}');

  Portable := TNewRadioButton.Create(WizardForm);
  with Portable do
  begin
    Parent := WizardForm.SelectDirPage;
    Left := ScaleX(110);
    Top := ScaleY(175);
    Width := ScaleX(100);
    Height := ScaleY(17);
    Caption := 'Портативная';
    Checked := CheckParam('/P');
  end;

  Installer := TNewRadioButton.Create(WizardForm);
  with Installer do
  begin
    Parent := WizardForm.SelectDirPage;
    Left := ScaleX(0);
    Top := ScaleY(175);
    Width := ScaleX(100);
    Height := ScaleY(17);
    Caption := 'Стационарная';
    Checked := not CheckParam('/P');
  end;
end;

Portable
start /wait setup.exe /VERYSILENT /P 
Installer
start /wait setup.exe /VERYSILENT /I

Last edited by pakrat2k2; 05-03-2018 at 21:05.
Reply With Quote