Mrrrr's Forum (VIEW ONLY)
Un forum care ofera solutii pentru unele probleme legate in general de PC. Pe langa solutii, aici puteti gasi si alte lucruri interesante // A forum that offers solutions to some PC related issues. Besides these, here you can find more interesting stuff.
Lista Forumurilor Pe Tematici
Mrrrr's Forum (VIEW ONLY) | Reguli | Inregistrare | Login

POZE MRRRR'S FORUM (VIEW ONLY)

Nu sunteti logat.
Nou pe simpatie:
pirsinga
Femeie
25 ani
Suceava
cauta Barbat
25 - 38 ani
Mrrrr's Forum (VIEW ONLY) / Tutoriale si Ghiduri Utile // Tutorials and useful guides / [Inno Setup] Making Install Setup for Your Programs Moderat de TRaP, TonyTzu
Autor
Mesaj Pagini: 1
Mrrrr
AdMiN

Inregistrat: acum 17 ani
Postari: 2186
I like to backup some of my Epic and Steam games to DVDs, since I payed for them I think I'm entitled to, instead of redownloading the whole 20 GB again and again...

The following is a simple script to make a setup with Inno Setup:

The game must first be installed.

Script below is made in Inno Setup and saved as .iss file (comments in this color)



#define MyTargetDir "DESIRED_PATH_OF_INSTALL_FROM_DVD"
#define MySourceDir "CURRENT_INSTALL_FOLDER"
#define MyAppName "GAME_NAME"
#define MyAppVersion "GAME_VERSION"
#define MyAppExeName "GAME_EXE.exe"
#define SetupName "DESIRED_NAME_OF_SETUP_FILE"
#define SetupIcon "icon.ico" [color=#ebadeb]; cannot add an executable here with ,0 after

#define LeftMessage "SMALL_MESSAGE" ; eg. your name :)
#define CompressMethod "lzma2/max" ; zip/1 or lzma2/max   I use zip/1 to test and lzma2/max for final compression

[Setup]
AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppVerName={#MyAppName} {#MyAppVersion}
WizardStyle=modern
DefaultDirName={#MyTargetDir}\{#MyAppName}
DefaultGroupName={#MyAppName}
UninstallDisplayIcon={app}\unins000.exe
OutputBaseFilename={#SetupName}
SetupIconFile={#MySourceDir}\{#SetupIcon}
DisableWelcomePage=no
DisableDirPage=no


; set an image to appear in the top right corner of the setup, square resolution
        ;WizardSmallImageFile="PATH\img_Small.bmp"
; set an image to appear on the left side of the setup, at the very end, something like W x H = 30 x 100
        ;WizardImageFile="PATH\img.bmp"
; ####


Compression={#CompressMethod}

; ####
; highest compression below, slow compress / decompress ~~~~ disable the above to enable the following 5 lines
        ;Compression=lzma2/ultra64
        ;LZMAUseSeparateProcess=yes
        ;LZMADictionarySize=1048576
        ;LZMANumFastBytes=273
        ;LZMANumBlockThreads=4
; number of cores needed is times 2 - LZMANumBlockThreads=4 x 2 = 8 cores needed
; ####


SolidCompression=yes
OutputDir={#MyTargetDir}\{#MyAppName}

; DiskSpanning is required if compress files get larger than ~ 2 GB / file
        DiskSpanning=yes

; split to parts - start - 3 parts = 1 DVD perfect fit = 4,37 GB
        SlicesPerDisk=3
        DiskSliceSize=1566000000
; ####

[Files]
Source: "{#MySourceDir}\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs

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

[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
Name: "{userdesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon

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

[Messages]
BeveledLabel={#LeftMessage}


_______________________________________


pus acum 1 an
   
Mrrrr
AdMiN

Inregistrat: acum 17 ani
Postari: 2186
Added the 2 lines in gold so that the install script shows the welcome page and directory select page by default. In the latest version of Inno Setup, the 2 pages are disabled by default.

_______________________________________


pus acum 1 an
   
Mrrrr
AdMiN

Inregistrat: acum 17 ani
Postari: 2186
If for example you want to name your setup file as the name of the app but with _ instead of spaces in the name.
Also if any - string is contained in the name of the app, I want that removed, so it doesn't appear in the setup name

Example:
My app name is: AAAA BBB - CC D
I want my setup name to be: AAAA_BBB_CC_D



#define MyAppName "AAAA BBB CC D"
#define SetupNameTmp StringChange(MyAppName, "- ", "") ; temporary name where I am removing the minus by replacing it + a space ("- ") with nothing ("")
#define SetupName StringChange(SetupNameTmp, " ", "_") ; final setup name where I am replacing the spaces (" ") with underscore ("_")


_______________________________________


pus acum 10 luni
   
Mrrrr
AdMiN

Inregistrat: acum 17 ani
Postari: 2186
If you want to add constants in another constant, for example if you want your setup name to also contain your app version number plus the word "Setup" in the end.

We can take the example in the post above, and here is the code to do the above (I marked the added lines in gold)



#define MyAppName "AAAA BBB CC D"
#define MyAppVersion "v1.2.0"
#define SetupNameTmp StringChange(MyAppName, "- ", "")
#define SetupName StringChange(SetupNameTmp, " ", "_") + "_" + MyAppVersion + "_Setup" ; so using the + sign I can add other constants and strings


Resulting setup file name will be:
AAAA_BBB_CC_D_v1.2.0_Setup


_______________________________________


pus acum 10 luni
   
Mrrrr
AdMiN

Inregistrat: acum 17 ani
Postari: 2186
Add a description page, you can use bold, underline, italic, text colors etc., but can't use images:

#define NfoFile MySourceDir + "\DESCRIPTION.rtf"     ; IF FILE EXISTS, can be txt or rtf

[Setup]
#if FileExists(NfoFile)
    InfoBeforeFile={#NfoFile}
#endif


_______________________________________


pus acum 8 luni
   
Mrrrr
AdMiN

Inregistrat: acum 17 ani
Postari: 2186
Another way to add images:

#define LargeImage "big.bmp"   ; must be BMP file; W x H like 200 x 385 or H = W * 1,925
#define SmallImage "small.bmp"   ; must be BMP file; W x H like 30 x 30, square
#define MyTemp MyTargetDir + "\" + "TEMP"       ; temp folder, eg with the two images above

[Setup]
#define MyImageL MyTemp + "\" + LargeImage
#define MyImageS MyTemp + "\" + SmallImage
#if DirExists(MyTemp)
  #if FileExists(MyImageL)
    WizardImageFile={#MyTemp}\{#LargeImage}
  #endif
  #if FileExists(MyImageS)
    WizardSmallImageFile={#MyTemp}\{#SmallImage}
  #endif
#endif 


Sources:


_______________________________________


pus acum 8 luni
   
Mrrrr
AdMiN

Inregistrat: acum 17 ani
Postari: 2186
Change uninstall executable location, since you can't change its name:

[Setup]
UninstallFilesDir={app}\Uninstall
UninstallDisplayIcon={app}\Uninstall\unins000.exe


_______________________________________


pus acum 8 luni
   
Mrrrr
AdMiN

Inregistrat: acum 17 ani
Postari: 2186
Conditional compression:


;#define CompressMethod "zip/1"          ; TEST ONLY
#define CompressMethod "lzma2/max"      ; FINAL COMPRESSION

[Setup]
Compression={#CompressMethod}

#if "lzma2/max" == CompressMethod
  CompressionThreads=auto
  LZMANumBlockThreads=3
  LZMAUseSeparateProcess=yes
  LZMADictionarySize=65536
  LZMABlockSize=262144

#elif "lzma2/ultra" == CompressMethod 
  SolidCompression=yes
  CompressionThreads=auto
  LZMANumBlockThreads=3
  LZMADictionarySize=1048576
  LZMANumFastBytes=273

#else
  #error Compress method set to other than lzma2/max or lzma2/ultra
  ;SolidCompression=yes
#endif


Sources:


_______________________________________


pus acum 8 luni
   
Mrrrr
AdMiN

Inregistrat: acum 17 ani
Postari: 2186
Add required files (DirectX, Visual C++ Redistributable etc.) so they appear as options on the last page, after install:

#define RedistExeDX "_CommonRedist\DirectX\Jun2010\DXSETUP.exe"
#define RedistExeVCx64 "_CommonRedist\vcredist\2022\VC_redist.x64.exe"
#define RedistExeVCx86 "_CommonRedist\vcredist\2022\VC_redist.x86.exe"
#define RedistSilentVCx64 "_CommonRedist\vcredist\2022\Microsoft Visual C++ 2022 x64.cmd"
#define RedistSilentVCx86 "_CommonRedist\vcredist\2022\Microsoft Visual C++ 2022 x86.cmd"

[Run]
Filename: "{app}\{#RedistExeDX}"; Description: "Install DirectX"; Flags: nowait postinstall skipifsilent unchecked
Filename: "{app}\{#RedistExeVCx64}"; Description: "Install Visual C++ 2022 x64 manually"; Flags: nowait postinstall skipifsilent unchecked
Filename: "{app}\{#RedistExeVCx86}"; Description: "Install Visual C++ 2022 x86 manually"; Flags: nowait postinstall skipifsilent unchecked
Filename: "{app}\{#RedistSilentVCx64}"; Description: "Install Visual C++ 2022 x64 silently"; Flags: nowait postinstall skipifsilent
Filename: "{app}\{#RedistSilentVCx86}"; Description: "Install Visual C++ 2022 x86 silently"; Flags: nowait postinstall skipifsilent


_______________________________________


pus acum 8 luni
   
Mrrrr
AdMiN

Inregistrat: acum 17 ani
Postari: 2186
Add message on first page of the setup, using red emboldened text:

[Messages]
WelcomeLabel2=THIS GAME REQUIRES A CONTROLLER!%n%nIt will not work without one!%n%nGame data is stored in %USERPROFILE%\Documents\Need for Speed Heat

[Code]
; under the following procedure you might have more code, the "Bold" and "Red" lines can be added right after "begin", just as below
procedure InitializeWizard;
begin
  WizardForm.WelcomeLabel2.Font.Style := [fsBold]; //Bold
  WizardForm.WelcomeLabel2.Font.Color := clRed; // Red

// any other code goes here

end;


_______________________________________


pus acum 8 luni
   
Mrrrr
AdMiN

Inregistrat: acum 17 ani
Postari: 2186
Custom Code section with "insert desired username" page, and add countdown timer on install progress page. The 2 lines in the Setup section are also required.


[Setup]
DisableWelcomePage=no
DisableDirPage=no

[Code]

var
  CustomQueryPage: TInputQueryWizardPage; { added this var for username input page }

function GetTickCount: DWORD;
  external 'GetTickCount@kernel32.dll stdcall';

var
  StartTick: DWORD;
  PercentLabel: TNewStaticText;
  ElapsedLabel: TNewStaticText;
  RemainingLabel: TNewStaticText;

procedure AddTime(var S: string; Count: Integer; L: string);
begin
  if Count > 0 then
  begin
    if S <> '' then
    begin
      S := S + ' ';
    end;
    if Count > 1 then L := L + 's';
    S := S + Format('%d %s', [Count, L]);
  end;
end;

function TicksToStr(Value: DWORD): string;
var
  I: DWORD;
  Hours, Minutes, Seconds: Integer;
begin
  I := Value div 1000;
  Seconds := I mod 60;
  I := I div 60;
  Minutes := I mod 60;
  I := I div 60;
  Hours := I mod 24;

  AddTime(Result, Hours, 'hour');
  AddTime(Result, Minutes, 'minute');
  AddTime(Result, Seconds, 'second');
  if Result = '' then Result := '-'; { no time }
end;

{ added this entire procedure for username input page }
procedure AddCustomQueryPage();
begin
  CustomQueryPage := CreateInputQueryPage(
    wpWelcome,
    'Change name of your player',
    '',
    'What do you want your user name to be in-game?');

  { Add items (False means it's not a password edit, as in it won't have to hide what you type under asterisks) }
  CustomQueryPage.Add('User name:', False);
 
  CustomQueryPage.Values[0] := 'Mrrrr';
end;

procedure InitializeWizard;
begin

  AddCustomQueryPage(); {added this line from input box }
  PercentLabel := TNewStaticText.Create(WizardForm);
  PercentLabel.Parent := WizardForm.ProgressGauge.Parent;
  PercentLabel.Left := 0;
  PercentLabel.Top := WizardForm.ProgressGauge.Top +
    WizardForm.ProgressGauge.Height + 12;

  ElapsedLabel := TNewStaticText.Create(WizardForm);
  ElapsedLabel.Parent := WizardForm.ProgressGauge.Parent;
  ElapsedLabel.Left := 0;
  ElapsedLabel.Top := PercentLabel.Top + PercentLabel.Height + 4;

  RemainingLabel := TNewStaticText.Create(WizardForm);
  RemainingLabel.Parent := WizardForm.ProgressGauge.Parent;
  RemainingLabel.Left := 0;
  RemainingLabel.Top := ElapsedLabel.Top + ElapsedLabel.Height + 4;
end;

{ added this entire procedure for username input page }
procedure CurStepChanged(CurStep: TSetupStep);
var
  IniFileName: string;
  IniFileName2: string; // You can add multiple IniFileName variables and edit multiple ini files, but with the same username
begin
  if CurStep = ssPostInstall then
  begin
    { Read custom value }
    { MsgBox('Your user name is = ' + CustomQueryPage.Values[0], mbInformation, MB_OK); }

    IniFileName := ExpandConstant('{app}\x64\FILENAME.ini');
    IniFileName2 := ExpandConstant('{app}\x86\FILENAME.ini');
    { SetIniString syntax: Section, Key, Value, Filename}
    SetIniString('Settings', 'UserName', CustomQueryPage.Values[0], IniFileName);
    SetIniString('Settings', 'UserName', CustomQueryPage.Values[0], IniFileName2);
  end;
end;

procedure CurPageChanged(CurPageID: Integer);
begin
{ if CurPageID = wpWelcome then
    WizardForm.Caption := 'Welcome to MyAppName'; }

  if CurPageID = wpInstalling then
    StartTick := GetTickCount;
{ if CurPageID = wpFinished then
    WizardForm.Caption := 'MyApp Installation Complete!';
    WizardForm.FinishedLabel.Caption := 'Congratulations! MyApp installation is complete! Enjoy!';  }

end;

procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);
begin
  if CurPageID = wpInstalling then
  begin
    Cancel := False;
    if ExitSetupMsgBox then
    begin
      Cancel := True;
      Confirm := False;
      PercentLabel.Visible := False;
      ElapsedLabel.Visible := False;
      RemainingLabel.Visible := False;
    end;
  end;
end;

procedure CurInstallProgressChanged(CurProgress, MaxProgress: Integer);
var
  CurTick: DWORD;
begin
  CurTick := GetTickCount;
  PercentLabel.Caption :=
    Format('Done: %.2f %%', [(CurProgress * 100.0) / MaxProgress]);
  ElapsedLabel.Caption :=
    Format('Elapsed: %s', [TicksToStr(CurTick - StartTick)]);
  if CurProgress > 0 then
  begin
    RemainingLabel.Caption :=
      Format('Remaining: %s', [TicksToStr(
        ((CurTick - StartTick) / CurProgress) * (MaxProgress - CurProgress))]);
  end;
end;


You can add multiple fields on the custom query page, see this:


_______________________________________


pus acum 8 luni
   
Pagini: 1  

Mergi la