Creation installation file in Inno Setup

In Visual Studio Express Edition there is no possibility to create instalation file for our projects. There is not such a function? In order to create exe file help us Inno Setup Compiler. This is free tool to create installation files.

Attention! This post has been published on my old website that has been down. Inno Setup was used long time ago by me, but I’m archive old posts for possible future use. Please be careful when using this post content.

If there is no need to build advanced installer – Inno Setup helps us to create it in one minute. But if someone want to add some extensions then Pascal has to be used to write code.

My VB Visual Studio project required three following things:
1. checking if Net.Framework >= 3.5 package is installed on local computer
2. checking if SQL SERVER CE 4.0 is installed on local computer
3. possibility to remove previous version when installing new one

My installer checks if Net.Framework and SQL SERVER are installed. What more, there is an option to download required files directly from website where packages have been published. Installer checks if previous version is already installed – if yes user might remove it.

Pay attention on AppId. If new version has been created, AppId has to be same as in previous version:

AppId={{809B9E8D-0216-4263-83D9-B2A87E4AB658}

In installer code AppId is mentioned in two places, there where installer checks id previous version is installed:

sUnInstPath := ExpandConstant('Software\Microsoft\Windows\CurrentVersion\Uninstall\{{809B9E8D-0216-4263-83D9-B2A87E4AB658}_is1'); //Your App GUID/ID
if RegValueExists(HKEY_LOCAL_MACHINE,'Software\Microsoft\Windows\CurrentVersion\Uninstall\{809B9E8D-0216-4263-83D9-B2A87E4AB658}_is1', 'UninstallString') then  //Your App GUID/ID

Quite important is code part in section [Dirs]. It allows to install our app on limited account (user account, not admin) in Widnows. Thanks to [Dirs] Windows will ask user to write admin password in order to install app:

[Dirs]
Name: "{app}\"; Permissions: everyone-modify

Unfortunately i don’t remember from where I took code to check if Net.Framework i SQL SERVER CE are installed. Removing previous app version has been took from this site:
http://stackoverflow.com/questions/11739317/how-to-detect-old-installation-and-offer-removal

Comparing original code following part has been add to comment:

//sUnInstallString := GetUninstallString();

Removing this part of code was needed because when installer detected previous version then it asked to remove old version. It doesn’t make sense because this question was asked when installer have been run.

Of course basic code has been created in Inno Setup creator in order to modify it later. Below whole code from Inno Setup to create installer file:

; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "Nazwa mojej aplikacji"
#define MyAppVersion "1.1.0.0"
#define MyAppPublisher "Pawel Bartkowiak"
#define MyAppURL "http://localhost/pawelbartkowiak/_public_html/wordpress/"
#define MyAppExeName "NazwaInstalatora.exe"

[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{809B9E8D-0216-4263-83D9-B2A87E4AB658}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
AllowNoIcons=yes
OutputBaseFilename=GeneratorSetupRozszerzony_wer1100Final
Compression=lzma
SolidCompression=yes

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
Name: "polish"; MessagesFile: "compiler:Languages\Polish.isl"

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

[Files]
Source: "C:\Users\Pawel\Documents\Visual Studio 2012\Projects\Nazwa Projektu\bin\Debug\Instalator.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\Pawel\Documents\Visual Studio 2012\Projects\Nazwa Projektu\bin\Debug\BazaGrzejniki.sdf"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

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

[Dirs]
Name: "{app}\"; Permissions: everyone-modify

[CustomMessages]
dotnetmissing1=Minimum Microsoft .NET Framework 3.5 is required. Would you like to download it?
dotnetmissing2=SQL SERVER CE 4.0 is required. Would you like to download it?
  
[code]
function CheckDotNetFx(): Boolean;
begin
    Result:= RegKeyExists(HKLM, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5');
end;

function CheckSSCE(): Boolean;
begin
    Result:= RegKeyExists(HKLM, 'SOFTWARE\Microsoft\Microsoft SQL Server Compact Edition\v4.0');
end;

function CheckIsReady(): Boolean;
begin
    Result:= CheckDotNetFx() and CheckSSCE();
end;

function GetUninstallString: string;
var
  sUnInstPath: string;
  sUnInstallString: String;
begin
  Result := '';
  sUnInstPath := ExpandConstant('Software\Microsoft\Windows\CurrentVersion\Uninstall\{{809B9E8D-0216-4263-83D9-B2A87E4AB658}_is1'); //Your App GUID/ID
  sUnInstallString := '';
  if not RegQueryStringValue(HKLM, sUnInstPath, 'UninstallString', sUnInstallString) then
    RegQueryStringValue(HKCU, sUnInstPath, 'UninstallString', sUnInstallString);
  Result := sUnInstallString;
end;

function IsUpgrade: Boolean;
begin
  Result := (GetUninstallString() <> '');
end;

function InitializeSetup(): Boolean;
var Path:string;
   //ResultCode: Integer;
    ErrorCode: Integer;
    V: Integer;
    iResultCode: Integer;
    sUnInstallString: string;
   
begin
   
   // Checking if net.framework 3.5 is installed
  if not CheckDotNetFx() then
  begin
   if (MsgBox(ExpandConstant('{cm:dotnetmissing1}'), mbConfirmation, MB_YESNO) = idYes)then
   
  begin
      ShellExec('open',
      'http://www.microsoft.com/pl-pl/download/details.aspx?id=22',
      '','',SW_SHOWNORMAL,ewNoWait,ErrorCode);
    end;
    result := false;
  end;
  
  // Checking if  SQL SERVER CE 4.0 is installed
  if not CheckSSCE() then
 begin
   if (MsgBox(ExpandConstant('{cm:dotnetmissing2}'), mbConfirmation, MB_YESNO) = idYes)then
  begin
      ShellExec('open',
      'http://www.microsoft.com/pl-pl/download/details.aspx?id=17876',
      '','',SW_SHOWNORMAL,ewNoWait,ErrorCode);
    end;
    result := false;
  end;

    Result := CheckIsReady();

 // http://stackoverflow.com/questions/11739317/how-to-detect-old-installation-and-offer-removal
begin
  Result := True; // in case when no previous version is found
  if RegValueExists(HKEY_LOCAL_MACHINE,'Software\Microsoft\Windows\CurrentVersion\Uninstall\{809B9E8D-0216-4263-83D9-B2A87E4AB658}_is1', 'UninstallString') then  //Your App GUID/ID
  begin
    V := MsgBox(ExpandConstant('Earlier version detected - it should be removed. Would you like to remove it?'), mbInformation, MB_YESNO); //Custom Message if App installed
    if V = IDYES then
    begin
      //sUnInstallString := GetUninstallString();
      sUnInstallString :=  RemoveQuotes(sUnInstallString);
      Exec(ExpandConstant(sUnInstallString), '', '', SW_SHOW, ewWaitUntilTerminated, iResultCode);
      Result := True; //if you want to proceed after uninstall
                //Exit; //if you want to quit after uninstall
    end
    else
      Result := False; //when older version present and not uninstalled
  end;
end;
end;

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

48 thoughts on “Creation installation file in Inno Setup

  1. Pingback: Homepage

  2. Pingback: number game

  3. Pingback: cá độ bóng đá ảo

  4. Pingback: số đề con chó

  5. Pingback: buy rishi turkey tail Magic Mushroom pills Capsules trip drug online for sale near me in USA Canada UK Australia overnight delivery cheap

  6. Pingback: trang web đánh lô đề uy tín

  7. Pingback: her response

  8. Pingback: nam mo thay ran danh con gi

  9. Pingback: game poker đổi thưởng

  10. Pingback: replica watch forums

  11. Pingback: Eat Verts

  12. Pingback: buy peyote cactu gta mescaline plant online for sale near me in USA Canada UK Australia overnight delivery cheap

  13. Pingback: Blazing Trader

  14. Pingback: English bulldog puppies for sale near me in CA ON MA CO OH PA SC MS TN FL UT NH VA AL TX

  15. Pingback: is bitcoin loophole a fake?

  16. Pingback: press brake machine

  17. Pingback: bitcoin era media review

  18. Pingback: bitcoin evolution

  19. Pingback: Gazzy Colon

  20. Pingback: SKBproductionsllc Film in Atlanta

  21. Pingback: bitcoin evolution

  22. Pingback: mơ thấy tiền đánh con gì

  23. Pingback: mơ thấy gạo đánh con gì

  24. Pingback: Pomsky breeders

  25. Pingback: Social Media Marketing

  26. Pingback: mo nhat duoc vang

  27. Pingback: Jungle Boys |Jungle Boys weed | Jungle Boys strains |Buy Jungle Boys Online | Jungle Boys Dispensary

  28. Pingback: SSCN BKN 2021 Kabupaten Bungo

  29. Pingback: mơ thấy thuyền đánh con gì

  30. Pingback: BP-12

  31. Pingback: AR-12 Pro

  32. Pingback: nằm mơ thấy máu

  33. Pingback: XFINITY Store by Comcast

  34. Pingback: nằm mơ thấy người thân bị bệnh

  35. Pingback: chiem bao thay lua

  36. Pingback: nằm mơ thấy rắn hổ mang đen

  37. Pingback: mơ thấy cá chép đánh con gì

  38. Pingback: xep hang 12 chom sao

  39. Pingback: mơ thấy mít chín đánh con gì

  40. Pingback: bảo bình hợp với cung nào nhất

  41. Pingback: cung song ngu nam

  42. Pingback: giải mã giấc mơ thấy người yêu cũ

  43. Pingback: giải mã ác mộng

  44. Pingback: mơ thấy đi xe đạp

  45. Pingback: tennis truc tuyen

  46. Pingback: mơ bị đứt tay

  47. Pingback: game dua ngua dat cuoc

  48. Pingback: Data Pengeluaran Sgp

Leave a Reply

Your email address will not be published. Required fields are marked *