setup warning

setup warning

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

#define MyAppName "ioBroker automation platform"
#define MyAppShortName "ioBroker"
#define MyAppLCShortName "iobroker"
#define MyAppVersion "@@version"
#define MyAppPublisher "ioBroker GmbH"
#define MyAppURL "https://www.ioBroker.net/"
#define MyAppIcon "ioBroker.ico"

[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={{97DA02F5-2E8C-4B96-BB42-61ED2BBF34DF}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={drive:{commonpf}}\ioBroker
;DisableDirPage=yes
DefaultGroupName={#MyAppName}
DisableProgramGroupPage=yes
OutputDir=..\..\delivery
OutputBaseFilename={#MyAppShortName}Installer.{#MyAppVersion}
SetupIconFile={#MyAppIcon}
Compression=lzma
SolidCompression=yes
UsePreviousAppDir=yes
ArchitecturesInstallIn64BitMode=x64
UninstallDisplayIcon={app}\{#MyAppIcon}
CloseApplications=yes
MissingRunOnceIdsWarning=no

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
Name: "german";  MessagesFile: "compiler:Languages\German.isl"
Name: "russian"; MessagesFile: "compiler:Languages\Russian.isl"

; enable scripting to force admin mode
[Registry]
Root: HKLM; Subkey: "Software\Microsoft\Windows Script Host\Settings"; ValueType: dword; ValueName: "Enabled"; ValueData: "00000001"

[Files]
Source: "nodejs\node.msi"; DestDir: "{app}"; Flags: ignoreversion deleteafterinstall; Check: not Is64BitInstallMode
Source: "nodejs\node-x64.msi"; DestDir: "{app}"; DestName: "node.msi"; Flags: ignoreversion deleteafterinstall; Check: Is64BitInstallMode
Source: "{#MyAppIcon}"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Icons]
Name: "{group}\{#MyAppShortName} Settings"; Filename: "http://localhost:8081"; IconFilename: "{app}\{#MyAppIcon}"
Name: "{group}\Uninstall {#MyAppShortName}"; Filename: "{uninstallexe}"; IconFilename: {app}\{#MyAppIcon};
Name: "{group}\{#MyAppShortName} Uninstall"; Filename: "{uninstallexe}"; IconFilename: {app}\{#MyAppIcon};
Name: "{group}\Start {#MyAppShortName} Service"; Filename: "{app}\serviceIoBroker.bat"; Parameters: "start"
Name: "{group}\Stop {#MyAppShortName} Service"; Filename: "{app}\serviceIoBroker.bat"; Parameters: "stop"
Name: "{group}\Restart {#MyAppShortName} Service"; Filename: "{app}\serviceIoBroker.bat"; Parameters: "restart"

[Code]
function PrepareToInstall(var NeedsRestart: Boolean): String;
var
  ResultCode: integer;
begin
  Result := '';
  if FileExists(ExpandConstant('{app}\serviceIoBroker.bat')) then begin
     Exec(ExpandConstant('{app}\serviceIoBroker.bat'), 'stop', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
  end;
end;

function FileReplaceString(const FileName, SearchString, ReplaceString: string):boolean;
var
  MyFile : TStrings;
  MyText : string;
begin
  MyFile := TStringList.Create;

  try
    result := true;

    try
      MyFile.LoadFromFile(FileName);
      MyText := MyFile.Text;

      if StringChangeEx(MyText, SearchString, ReplaceString, True) > 0 then //Only save if text has been changed.
      begin;
        MyFile.Text := MyText;
        MyFile.SaveToFile(FileName);
      end;
    except
      result := false;
    end;
  finally
    MyFile.Free;
  end;
end;

procedure CurStepChanged(CurStep: TSetupStep);
var
  fileName : string;
  lang : string;
begin
  if  CurStep=ssPostInstall then
    begin
      lang := ActiveLanguage();
      if lang = 'russian' then begin
        lang := 'ru';
      end
      else begin
          if lang = 'german' then begin
            lang := 'de';
          end
          else begin
            lang := '';
          end;
      end;
      if lang <> '' then begin
          fileName := ExpandConstant('{app}\settings-dist.json');
          //FileReplaceString(fileName, '"language": "en"', '"language": "' + lang + '"');
      end;
    end;
end;

function NodeJsNeedsInstall():boolean;
var
  ResultCode: integer;
begin

  result := true;
  if IsWin64 then begin
      result := not FileExists(ExpandConstant('{commonpf64}\nodejs\node.exe'));

      if result then begin
        result := not FileExists(ExpandConstant('{commonpf32}\nodejs\node.exe'));
      end;
  end;

  if result then begin
    result := not FileExists(ExpandConstant('{commonpf}\nodejs\node.exe'));
  end;

  if not DirExists(ExpandConstant('{userappdata}\npm')) then begin
     Exec(ExpandConstant('mkdir'), ExpandConstant('{userappdata}\npm'), '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
  end;
  if not DirExists(ExpandConstant('{userappdata}\npm-cache')) then begin
     Exec(ExpandConstant('mkdir'), ExpandConstant('{userappdata}\npm-cache'), '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
  end;
end;

function NodeJsPath(Param: String):String;
begin
  result := '';

  if DirExists(ExpandConstant('{commonpf}\nodejs')) then begin
    result := ExpandConstant('{commonpf}\nodejs');
  end;

  if IsWin64 then begin
      if DirExists(ExpandConstant('{commonpf32}\nodejs')) then begin
        result := ExpandConstant('{commonpf32}\nodejs');
      end;

      if DirExists(ExpandConstant('{commonpf64}\nodejs')) then begin
        result := ExpandConstant('{commonpf64}\nodejs');
      end;
  end;
end;

function GetAdminPageText(Param: String):String;
begin
  result := 'Open settings page';

  if ActiveLanguage() = 'german' then begin
    result := 'Einstellungen aufmachen';
  end;

  if ActiveLanguage() = 'russian' then begin
      result := 'Открыть настройки';
  end;
end;

[Run]
; postinstall launch
Filename: "msiexec.exe"; Parameters: "/i ""{app}\node.msi"" /passive"; Check: NodeJsNeedsInstall
;
;Filename: "{code:NodeJsPath}\npm.cmd"; Parameters: "install iobroker --prefix ""{app}""";
;Filename: "{code:NodeJsPath}\npm.cmd"; Parameters: "install --production"; WorkingDir: "{app}";
;Filename: "{app}\serviceIoBroker.bat"; Parameters: "start"; WorkingDir: "{app}";
;
Filename: "{code:NodeJsPath}\npx.cmd"; Parameters: "github:iobroker/iobroker#windows-installer"; WorkingDir: "{app}";
;
; Add Firewall Rules
; Filename: "{sys}\netsh.exe"; Parameters: "advfirewall firewall add rule name=""Node In"" program=""{code:NodeJsPath}\node.exe"" dir=in action=allow enable=yes"; Flags: runhidden;
; Filename: "{sys}\netsh.exe"; Parameters: "advfirewall firewall add rule name=""Node Out"" program=""{code:NodeJsPath}\node.exe"" dir=out action=allow enable=yes"; Flags: runhidden;
Filename: http://localhost:8081/; Description: "{code:GetAdminPageText}"; Flags: postinstall shellexec

[UninstallDelete]
Type: filesandordirs; Name: "{app}\daemon"
Type: filesandordirs; Name: "{app}\node_modules"
Type: filesandordirs; Name: "{app}\install"
Type: filesandordirs; Name: "{app}\iobroker-data"
Type: filesandordirs; Name: "{app}\log"
Type: filesandordirs; Name: "{app}\*.js"
Type: filesandordirs; Name: "{app}\*.md"
Type: filesandordirs; Name: "{app}\*.cmd"
Type: filesandordirs; Name: "{app}\*.bat"
Type: filesandordirs; Name: "{app}\*.json"
Type: filesandordirs; Name: "{app}\*.ps1"
Type: filesandordirs; Name: "{app}\*.sh"
Type: filesandordirs; Name: "{app}\LICENSE"
Type: filesandordirs; Name: "{app}\semver"

[UninstallRun]
; Removes System Service
Filename: "{code:NodeJsPath}\node.exe"; Parameters: """{app}\uninstall.js"""; Flags: runhidden;
;Filename: "{sys}\del"; Parameters: "/Q /S ""{app}\daemon""";
;Filename: "{sys}\rmdir"; Parameters: "/Q /S ""{app}\daemon""";
;Filename: "{sys}\del"; Parameters: "/Q /S ""{app}\node_modules""";
;Filename: "{sys}\rmdir"; Parameters: "/Q /S ""{app}\node_modules""";
; Remove Firewall Rules
; Filename: "{sys}\netsh.exe"; Parameters: "advfirewall firewall delete rule name=""Node In"" program=""{code:NodeJsPath}\node.exe"""; Flags: runhidden;
; Filename: "{sys}\netsh.exe"; Parameters: "advfirewall firewall delete rule name=""Node Out"" program=""{code:NodeJsPath}\node.exe"""; Flags: runhidden;
; Remove all leftovers

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

#define MyAppName "ioBroker automation platform"
#define MyAppShortName "ioBroker"
#define MyAppLCShortName "iobroker"
#define MyAppVersion "@@version"
#define MyAppPublisher "ioBroker GmbH"
#define MyAppURL "https://www.ioBroker.net/"
#define MyAppIcon "ioBroker.ico"

[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={{97DA02F5-2E8C-4B96-BB42-61ED2BBF34DF}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={drive:{commonpf}}\ioBroker
;DisableDirPage=yes
DefaultGroupName={#MyAppName}
DisableProgramGroupPage=yes
OutputDir=..\..\delivery
OutputBaseFilename={#MyAppShortName}Installer.{#MyAppVersion}
SetupIconFile={#MyAppIcon}
Compression=lzma
SolidCompression=yes
UsePreviousAppDir=yes
ArchitecturesInstallIn64BitMode=x64
UninstallDisplayIcon={app}\{#MyAppIcon}
CloseApplications=yes

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
Name: "german";  MessagesFile: "compiler:Languages\German.isl"
Name: "russian"; MessagesFile: "compiler:Languages\Russian.isl"

; enable scripting to force admin mode
[Registry]
Root: HKLM; Subkey: "Software\Microsoft\Windows Script Host\Settings"; ValueType: dword; ValueName: "Enabled"; ValueData: "00000001"

[Files]
Source: "nodejs\node.msi"; DestDir: "{app}"; Flags: ignoreversion deleteafterinstall; Check: not Is64BitInstallMode
Source: "nodejs\node-x64.msi"; DestDir: "{app}"; DestName: "node.msi"; Flags: ignoreversion deleteafterinstall; Check: Is64BitInstallMode
Source: "{#MyAppIcon}"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Icons]
Name: "{group}\{#MyAppShortName} Settings"; Filename: "http://localhost:8081"; IconFilename: "{app}\{#MyAppIcon}"
Name: "{group}\Uninstall {#MyAppShortName}"; Filename: "{uninstallexe}"; IconFilename: {app}\{#MyAppIcon};
Name: "{group}\{#MyAppShortName} Uninstall"; Filename: "{uninstallexe}"; IconFilename: {app}\{#MyAppIcon};
Name: "{group}\Start {#MyAppShortName} Service"; Filename: "{app}\serviceIoBroker.bat"; Parameters: "start"
Name: "{group}\Stop {#MyAppShortName} Service"; Filename: "{app}\serviceIoBroker.bat"; Parameters: "stop"
Name: "{group}\Restart {#MyAppShortName} Service"; Filename: "{app}\serviceIoBroker.bat"; Parameters: "restart"

[Code]
function PrepareToInstall(var NeedsRestart: Boolean): String;
var
  ResultCode: integer;
begin
  Result := '';
  if FileExists(ExpandConstant('{app}\serviceIoBroker.bat')) then begin
     Exec(ExpandConstant('{app}\serviceIoBroker.bat'), 'stop', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
  end;
end;

function FileReplaceString(const FileName, SearchString, ReplaceString: string):boolean;
var
  MyFile : TStrings;
  MyText : string;
begin
  MyFile := TStringList.Create;

  try
    result := true;

    try
      MyFile.LoadFromFile(FileName);
      MyText := MyFile.Text;

      if StringChangeEx(MyText, SearchString, ReplaceString, True) > 0 then //Only save if text has been changed.
      begin;
        MyFile.Text := MyText;
        MyFile.SaveToFile(FileName);
      end;
    except
      result := false;
    end;
  finally
    MyFile.Free;
  end;
end;

procedure CurStepChanged(CurStep: TSetupStep);
var
  fileName : string;
  lang : string;
begin
  if  CurStep=ssPostInstall then
    begin
      lang := ActiveLanguage();
      if lang = 'russian' then begin
        lang := 'ru';
      end
      else begin
          if lang = 'german' then begin
            lang := 'de';
          end
          else begin
            lang := '';
          end;
      end;
      if lang <> '' then begin
          fileName := ExpandConstant('{app}\settings-dist.json');
          //FileReplaceString(fileName, '"language": "en"', '"language": "' + lang + '"');
      end;
    end;
end;

function NodeJsNeedsInstall():boolean;
var
  ResultCode: integer;
begin

  result := true;
  if IsWin64 then begin
      result := not FileExists(ExpandConstant('{commonpf64}\nodejs\node.exe'));

      if result then begin
        result := not FileExists(ExpandConstant('{commonpf32}\nodejs\node.exe'));
      end;
  end;

  if result then begin
    result := not FileExists(ExpandConstant('{commonpf}\nodejs\node.exe'));
  end;

  if not DirExists(ExpandConstant('{userappdata}\npm')) then begin
     Exec(ExpandConstant('mkdir'), ExpandConstant('{userappdata}\npm'), '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
  end;
  if not DirExists(ExpandConstant('{userappdata}\npm-cache')) then begin
     Exec(ExpandConstant('mkdir'), ExpandConstant('{userappdata}\npm-cache'), '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
  end;
end;

function NodeJsPath(Param: String):String;
begin
  result := '';

  if DirExists(ExpandConstant('{commonpf}\nodejs')) then begin
    result := ExpandConstant('{commonpf}\nodejs');
  end;

  if IsWin64 then begin
      if DirExists(ExpandConstant('{commonpf32}\nodejs')) then begin
        result := ExpandConstant('{commonpf32}\nodejs');
      end;

      if DirExists(ExpandConstant('{commonpf64}\nodejs')) then begin
        result := ExpandConstant('{commonpf64}\nodejs');
      end;
  end;
end;

function GetAdminPageText(Param: String):String;
begin
  result := 'Open settings page';

  if ActiveLanguage() = 'german' then begin
    result := 'Einstellungen aufmachen';
  end;

  if ActiveLanguage() = 'russian' then begin
      result := 'Открыть настройки';
  end;
end;

[Run]
; postinstall launch
Filename: "msiexec.exe"; Parameters: "/i ""{app}\node.msi"" /passive"; Check: NodeJsNeedsInstall
;
;Filename: "{code:NodeJsPath}\npm.cmd"; Parameters: "install iobroker --prefix ""{app}""";
;Filename: "{code:NodeJsPath}\npm.cmd"; Parameters: "install --production"; WorkingDir: "{app}";
;Filename: "{app}\serviceIoBroker.bat"; Parameters: "start"; WorkingDir: "{app}";
;
Filename: "{code:NodeJsPath}\npx.cmd"; Parameters: "github:iobroker/iobroker#windows-installer"; WorkingDir: "{app}";
;
; Add Firewall Rules
; Filename: "{sys}\netsh.exe"; Parameters: "advfirewall firewall add rule name=""Node In"" program=""{code:NodeJsPath}\node.exe"" dir=in action=allow enable=yes"; Flags: runhidden;
; Filename: "{sys}\netsh.exe"; Parameters: "advfirewall firewall add rule name=""Node Out"" program=""{code:NodeJsPath}\node.exe"" dir=out action=allow enable=yes"; Flags: runhidden;
Filename: http://localhost:8081/; Description: "{code:GetAdminPageText}"; Flags: postinstall shellexec

[UninstallDelete]
Type: filesandordirs; Name: "{app}\daemon"
Type: filesandordirs; Name: "{app}\node_modules"
Type: filesandordirs; Name: "{app}\install"
Type: filesandordirs; Name: "{app}\iobroker-data"
Type: filesandordirs; Name: "{app}\log"
Type: filesandordirs; Name: "{app}\*.js"
Type: filesandordirs; Name: "{app}\*.md"
Type: filesandordirs; Name: "{app}\*.cmd"
Type: filesandordirs; Name: "{app}\*.bat"
Type: filesandordirs; Name: "{app}\*.json"
Type: filesandordirs; Name: "{app}\*.ps1"
Type: filesandordirs; Name: "{app}\*.sh"
Type: filesandordirs; Name: "{app}\LICENSE"
Type: filesandordirs; Name: "{app}\semver"

[UninstallRun]
; Removes System Service
Filename: "{code:NodeJsPath}\node.exe"; Parameters: """{app}\uninstall.js"""; Flags: runhidden;
;Filename: "{sys}\del"; Parameters: "/Q /S ""{app}\daemon""";
;Filename: "{sys}\rmdir"; Parameters: "/Q /S ""{app}\daemon""";
;Filename: "{sys}\del"; Parameters: "/Q /S ""{app}\node_modules""";
;Filename: "{sys}\rmdir"; Parameters: "/Q /S ""{app}\node_modules""";
; Remove Firewall Rules
; Filename: "{sys}\netsh.exe"; Parameters: "advfirewall firewall delete rule name=""Node In"" program=""{code:NodeJsPath}\node.exe"""; Flags: runhidden;
; Filename: "{sys}\netsh.exe"; Parameters: "advfirewall firewall delete rule name=""Node Out"" program=""{code:NodeJsPath}\node.exe"""; Flags: runhidden;
; Remove all leftovers


make the vs install silent

make the vs install silent

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

#define MyAppName "AnnwvynSDK64"
#define MyAppVersion "0.2.7"
#define MyAppPublisher "Arthur (Ybalrid) Brainville"
#define MyAppURL "http://annwvyn.org/"

[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.)
CompressionThreads=8
AppId={{B94D9F2F-7B8F-4B38-933A-16F6220B656B}}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName=C:\YbalridSoftware\{#MyAppName}
DefaultGroupName={#MyAppName}
AllowNoIcons=yes
LicenseFile=C:\YbalridSoftware\AnnwvynSDK64\Annwvyn\LICENSE
InfoAfterFile=C:\YbalridSoftware\AnnwvynSDK64\README.TXT
OutputDir=C:\YbalridSoftware\AnnwvynSetup64
OutputBaseFilename=setupAnnwvynSDKx64
Compression=lzma
SolidCompression=yes

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

[Files]
Source: "C:\YbalridSoftware\AnnwvynSDK64\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs ; Excludes: "*.sdf,*.ipch,*.pch, *.obj"
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Icons]
Name: "{group}\{cm:ProgramOnTheWeb,{#MyAppName}}"; Filename: "{#MyAppURL}"
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"

[Run]
Filename: "{app}\RUNME-64.BAT"
Filename: "{app}\Annwvyn\utils\vc_redist.x64.2015.exe /q"; StatusMsg: "Installing Visual C++ 2015 x64 redistribuable"; Check: IsWin64();

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

#define MyAppName "AnnwvynSDK64"
#define MyAppVersion "0.2.7"
#define MyAppPublisher "Arthur (Ybalrid) Brainville"
#define MyAppURL "http://annwvyn.org/"

[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.)
CompressionThreads=8
AppId={{B94D9F2F-7B8F-4B38-933A-16F6220B656B}}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName=C:\YbalridSoftware\{#MyAppName}
DefaultGroupName={#MyAppName}
AllowNoIcons=yes
LicenseFile=C:\YbalridSoftware\AnnwvynSDK64\Annwvyn\LICENSE
InfoAfterFile=C:\YbalridSoftware\AnnwvynSDK64\README.TXT
OutputDir=C:\YbalridSoftware\AnnwvynSetup64
OutputBaseFilename=setupAnnwvynSDKx64
Compression=lzma
SolidCompression=yes

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

[Files]
Source: "C:\YbalridSoftware\AnnwvynSDK64\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs ; Excludes: "*.sdf,*.ipch,*.pch, *.obj"
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Icons]
Name: "{group}\{cm:ProgramOnTheWeb,{#MyAppName}}"; Filename: "{#MyAppURL}"
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"

[Run]
Filename: "{app}\RUNME-64.BAT"
Filename: "{app}\Annwvyn\utils\vc_redist.x64.2015.exe"; StatusMsg: "Installing Visual C++ 2015 x64 redistribuable"; Check: IsWin64();


Python installer detects the 64 bit python installation

//
// PROJECT CHRONO - http://projectchrono.org
//
// Copyright (c) 2012 Alessandro Tasora
// Copyright (c) 2013 Project Chrono
// All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file at the top level of the distribution
// and at http://projectchrono.org/license-chrono.txt.
//

#include "ModifyPath.iss"

#define MyAppName "PyChronoEngine"
#define MyAppVersion "v1.8.0"
#define MyAppPublisher "Alessandro Tasora"
#define MyAppURL "http://www.chronoengine.info"
#define MyWin64PythonDir  "C:\Python33"
#define MyPythonVers "3.3"
#define MyChronoEngineSDK "C:\tasora\code\projectchrono\chrono"

[Setup]
ShowLanguageDialog=yes
UserInfoPage=no
AppName={#MyAppName}
AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
WizardImageFile=SetupModern20.bmp
WizardSmallImageFile=SetupModernSmall26.bmp
PrivilegesRequired=admin
;Compression=none
OutputDir=c:\tasora\lavori\data_chrono
OutputBaseFilename=PyChronoEngine_{#MyAppVersion}

[Files]
Source: {#MyChronoEngineSDK}\src\demos\data\*; Excludes: "*\.svn,\data\mpi"; DestDir: "{app}\data"; Flags: recursesubdirs createallsubdirs
Source: {#MyChronoEngineSDK}\src\demos\python\*; DestDir: "{app}\python"; Flags: recursesubdirs createallsubdirs

Source: {#MyWin64PythonDir}\DLLs\_ChronoEngine_PYTHON_core.pyd; DestDir: {code:myGetPathWin64PythonDLLs};  Flags: ignoreversion;  Check: myFoundWin64Python;
Source: {#MyWin64PythonDir}\DLLs\_ChronoEngine_PYTHON_postprocess.pyd; DestDir: {code:myGetPathWin64PythonDLLs};  Flags: ignoreversion;  Check: myFoundWin64Python;
Source: {#MyWin64PythonDir}\DLLs\_ChronoEngine_PYTHON_irrlicht.pyd; DestDir: {code:myGetPathWin64PythonDLLs};  Flags: ignoreversion;  Check: myFoundWin64Python;
Source: {#MyWin64PythonDir}\DLLs\_ChronoEngine_PYTHON_fem.pyd; DestDir: {code:myGetPathWin64PythonDLLs};  Flags: ignoreversion;  Check: myFoundWin64Python;
Source: {#MyWin64PythonDir}\DLLs\ChronoEngine.dll; DestDir: {code:myGetPathWin64PythonDLLs};  Flags: ignoreversion;  Check: myFoundWin64Python;
Source: {#MyWin64PythonDir}\DLLs\ChronoEngine_POSTPROCESS.dll; DestDir: {code:myGetPathWin64PythonDLLs};  Flags: ignoreversion;  Check: myFoundWin64Python;
Source: {#MyWin64PythonDir}\DLLs\ChronoEngine_IRRLICHT.dll; DestDir: {code:myGetPathWin64PythonDLLs};  Flags: ignoreversion;  Check: myFoundWin64Python;
Source: {#MyWin64PythonDir}\DLLs\ChronoEngine_FEM.dll; DestDir: {code:myGetPathWin64PythonDLLs};  Flags: ignoreversion;  Check: myFoundWin64Python;
Source: {#MyWin64PythonDir}\DLLs\Irrlicht.dll; DestDir: {code:myGetPathWin64PythonDLLs};  Flags: ignoreversion;  Check: myFoundWin64Python;
Source: {#MyWin64PythonDir}\lib\ChronoEngine_PYTHON_core.py; DestDir: {code:myGetPathWin64PythonLib};  Flags: ignoreversion;  Check: myFoundWin64Python;
Source: {#MyWin64PythonDir}\lib\ChronoEngine_PYTHON_postprocess.py; DestDir: {code:myGetPathWin64PythonLib};  Flags: ignoreversion;  Check: myFoundWin64Python;
Source: {#MyWin64PythonDir}\lib\ChronoEngine_PYTHON_irrlicht.py; DestDir: {code:myGetPathWin64PythonLib};  Flags: ignoreversion;  Check: myFoundWin64Python;
Source: {#MyWin64PythonDir}\lib\ChronoEngine_PYTHON_fem.py; DestDir: {code:myGetPathWin64PythonLib};  Flags: ignoreversion;  Check: myFoundWin64Python;

[Icons]
Name: "{group}\Getting started"; Filename: "http://www.chronoengine.info"
Name: "{group}\Demos"; Filename: "{app}\python"
Name: "{group}\Uninstall"; Filename: "{uninstallexe}"

[Code]
var
  DataDirPage: TInputDirWizardPage;
  mFoundWin32Python: Integer;
  mPathWin32Python: String;
  mPathWin32PythonLib: String;
  mPathWin32PythonDLLs: String;
  mFoundWin64Python: Integer;
  mPathWin64Python: String;
  mPathWin64PythonLib: String;
  mPathWin64PythonDLLs: String;

function myFoundWin32Python: Boolean;
begin
  Result := mFoundWin32Python =1;
end;
function myGetPathWin32Python(Param: String): String;
begin
  Result := mPathWin32Python;
end;
function myGetPathWin32PythonLib(Param: String): String;
begin
  Result := mPathWin32PythonLib;
end;
function myGetPathWin32PythonDLLs(Param: String): String;
begin
  Result := mPathWin32PythonDLLs;
end;
function myFoundWin64Python: Boolean;
begin
  Result := mFoundWin64Python =1;
end;
function myGetPathWin64Python(Param: String): String;
begin
  Result := mPathWin64Python;
end;
function myGetPathWin64PythonLib(Param: String): String;
begin
  Result := mPathWin64PythonLib;
end;
function myGetPathWin64PythonDLLs(Param: String): String;
begin
  Result := mPathWin64PythonDLLs;
end;

procedure InitializeWizard;
var
  mTitlePythondir: String;
  mallDirPython: String;
  mCut: Integer;
  myvers: String;
begin

  // CHECK PYTHON INSTALLATION
  mFoundWin32Python := 0;
  mFoundWin64Python := 0;

  myvers := '{#MyPythonVers}';

  if (IsWin64) then
  begin
    // CASE OF 64 BIT PLATFORM

        // find 64 bit python:
    if RegQueryStringValue(HKLM64,
                    'SOFTWARE\Python\PythonCore\' +  myvers+ '\InstallPath',
                    '',
                    mallDirPython) then
    begin
          MsgBox('FOUND! 64bit !'#13#13 + mallDirPython, mbError, MB_OK);
          mPathWin64Python := mallDirPython;
          mFoundWin64Python := 1;
    end

        // find 32 bit python:
    if RegQueryStringValue(HKEY_LOCAL_MACHINE,
                    'SOFTWARE\Wow6432Node\Python\PythonCore\' +  myvers+ '\InstallPath',
                    '',
                    mallDirPython) then
    begin
          mPathWin32Python := mallDirPython;
          mFoundWin32Python := 1;
    end

  end
  else
  begin
    // CASE OF 32 BIT PLATFORM

    // find 32 bit python:
    if RegQueryStringValue(HKEY_LOCAL_MACHINE,
                    'SOFTWARE\Python\PythonCore\' +  myvers+ '\InstallPath',
                    '',
                    mallDirPython) then
    begin
          mPathWin32Python := mallDirPython;
          mFoundWin32Python := 1;
    end

  end

  mPathWin32PythonDLLs := AddBackslash(mPathWin32Python) + 'DLLs';
  mPathWin32PythonLib  := AddBackslash(mPathWin32Python) + 'Lib';
  mPathWin64PythonDLLs := AddBackslash(mPathWin64Python) + 'DLLs';
  mPathWin64PythonLib  := AddBackslash(mPathWin64Python) + 'Lib';

  { Create the pages }

  //
  // Select directory dialog for plugin
  //
  if mFoundWin64Python = 1 then begin mTitlePythondir := 'A copy of 64bit Python has been automatically detected, installed in this directory.'#13+
                                   'Do NOT modify the installation path unless you know what you are doing:'#13+
                                   'the Chrono::Engine module works only if installed in the proper Python directory!';
                    end else begin mTitlePythondir := 'The installation directory of Python has NOT been automatically found!. '#13+
                                   'Nevertheless, you can still go on with the installation, something went'#13+
                                   'wrong with your registry keys. Note: set this directory so that it is the'#13+
                                   'directory where python.exe file is installed, for Win64 bit'#13+
                                   'for example  C:\Python33 '; end

  DataDirPage := CreateInputDirPage(wpWelcome,
    'Check Python directory', 'Where is your Python (version ' +  myvers + ' or following, 64bit) directory?',
    mTitlePythondir,
    False, '');
  DataDirPage.Add('');
  DataDirPage.Values[0] := Format('%s\', [mPathWin64Python] );

end;

function NextButtonClick(CurPageID: Integer): Boolean;
var
  I: Integer;
  mfilesize: Integer;
begin

  //
  // After the user has entered data...
  //
  if CurPageID = wpWelcome then begin

   //   if ((mFoundWin32Python = 0) and (mFoundWin64Python = 0) ) then begin
   //     mPathWin64Python := '{#MyWin64PythonDir}';
   //     MsgBox('WARNING!'#13#13+
   //            'The installer was not able to detect Python (version' +  '{#MyPythonVers}' + ') '+
   //            'on your system.'#13#13+
   //            'Maybe your Python (version' +  '{#MyPythonVers}' + ') is not yet installed, or not properly installed?'#13+
   //            '(If so,please install/reinstall Python 64 bit before installing this plug-in).', mbError, MB_OK);
   //  end;
   //
      Result := True;

  //
  // After the user has choosen python directory..
  //
  end else if CurPageID = DataDirPage.ID then begin

      mPathWin64Python     := DataDirPage.Values[0];
      mPathWin64PythonDLLs := AddBackslash(mPathWin64Python) + 'DLLs';
      mPathWin64PythonLib  := AddBackslash(mPathWin64Python) + 'Lib';

      if FileOrDirExists(mPathWin64Python) and FileOrDirExists(mPathWin64PythonDLLs) and FileOrDirExists(mPathWin64PythonLib) then begin
        Result := True;
        mFoundWin64Python :=1;
      end else begin
        MsgBox('Error. The directory '+ mPathWin64Python + ' does not exist', mbError, MB_OK);
        Result := False;
      end

  end else
      Result := True;
end;

function ShouldSkipPage(PageID: Integer): Boolean;
begin
  Result := False;

  { Skip pages that shouldn't be shown }

  if (PageID = wpSelectDir) then
    Result := True

  if ((PageId = DataDirPage.ID) and ((mFoundWin64Python =1) or (mFoundWin32Python =1)))  then
    Result := True
end;

function UpdateReadyMemo(Space, NewLine, MemoUserInfoInfo, MemoDirInfo, MemoTypeInfo,
  MemoComponentsInfo, MemoGroupInfo, MemoTasksInfo: String): String;
var
  S: String;
begin
  { Fill the 'Ready Memo' with the normal settings and the custom settings }
  S := '';

  if (mFoundWin32Python = 1) then begin
    S := S + 'A Win32 Python has been detected in:' + NewLine;
    S := S + Space + mPathWin32Python + NewLine;
    S := S + 'but the Chrono::Engine 32 bit module is NOT INCLUDED in this installer AND CANNOT BE INSTALLED!' + NewLine;
    //S := S + Space + mPathWin32PythonDLLs + NewLine;
    //S := S + Space + mPathWin32PythonLib + NewLine;
  end

  if ((mFoundWin64Python = 1) and (mFoundWin32Python = 0)) then begin
    S := S + 'A Win64 Python has been detected in:' + NewLine;
    S := S + Space + mPathWin64Python + NewLine;
    S := S + 'so the Chrono::Engine 64 bit module will be installed in:' + NewLine;
    //S := S + 'so the Chrono::Engine 64 bit module will be installed in:' + NewLine;
    S := S + Space + mPathWin64PythonDLLs + NewLine;
    S := S + Space + mPathWin64PythonLib + NewLine;
  end

  if ((mFoundWin64Python = 0) and  (mFoundWin32Python = 0)) then begin
    S := S + 'Neither Win32 nor Win64 Python (version' +  '{#MyPythonVers}' + ') has been detected.' + NewLine;
    S := S + 'Chrono::Engine module CANNOT BE INSTALLED!' + NewLine;
  end

  Result := S;
end;

//function CheckSerial(Serial: String): Boolean;
//begin
//   Result:=True;
//end;

//
// PROJECT CHRONO - http://projectchrono.org
//
// Copyright (c) 2012 Alessandro Tasora
// Copyright (c) 2013 Project Chrono
// All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file at the top level of the distribution
// and at http://projectchrono.org/license-chrono.txt.
//

#include "ModifyPath.iss"

#define MyAppName "PyChronoEngine"
#define MyAppVersion "v1.8.0"
#define MyAppPublisher "Alessandro Tasora"
#define MyAppURL "http://www.chronoengine.info"
#define MyWin64PythonDir  "C:\Python33"
#define MyPythonVers "3.3"
#define MyChronoEngineSDK "C:\tasora\code\projectchrono\chrono"

[Setup]
ShowLanguageDialog=yes
UserInfoPage=no
AppName={#MyAppName}
AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
WizardImageFile=SetupModern20.bmp
WizardSmallImageFile=SetupModernSmall26.bmp
PrivilegesRequired=admin
;Compression=none
OutputDir=c:\tasora\lavori\data_chrono
OutputBaseFilename=PyChronoEngine_{#MyAppVersion}

[Files]
Source: {#MyChronoEngineSDK}\src\demos\data\*; Excludes: "*\.svn,\data\mpi"; DestDir: "{app}\data"; Flags: recursesubdirs createallsubdirs
Source: {#MyChronoEngineSDK}\src\demos\python\*; DestDir: "{app}\python"; Flags: recursesubdirs createallsubdirs

Source: {#MyWin64PythonDir}\DLLs\_ChronoEngine_PYTHON_core.pyd; DestDir: {code:myGetPathWin64PythonDLLs};  Flags: ignoreversion;  Check: myFoundWin64Python;
Source: {#MyWin64PythonDir}\DLLs\_ChronoEngine_PYTHON_postprocess.pyd; DestDir: {code:myGetPathWin64PythonDLLs};  Flags: ignoreversion;  Check: myFoundWin64Python;
Source: {#MyWin64PythonDir}\DLLs\_ChronoEngine_PYTHON_irrlicht.pyd; DestDir: {code:myGetPathWin64PythonDLLs};  Flags: ignoreversion;  Check: myFoundWin64Python;
Source: {#MyWin64PythonDir}\DLLs\_ChronoEngine_PYTHON_fem.pyd; DestDir: {code:myGetPathWin64PythonDLLs};  Flags: ignoreversion;  Check: myFoundWin64Python;
Source: {#MyWin64PythonDir}\DLLs\ChronoEngine.dll; DestDir: {code:myGetPathWin64PythonDLLs};  Flags: ignoreversion;  Check: myFoundWin64Python;
Source: {#MyWin64PythonDir}\DLLs\ChronoEngine_POSTPROCESS.dll; DestDir: {code:myGetPathWin64PythonDLLs};  Flags: ignoreversion;  Check: myFoundWin64Python;
Source: {#MyWin64PythonDir}\DLLs\ChronoEngine_IRRLICHT.dll; DestDir: {code:myGetPathWin64PythonDLLs};  Flags: ignoreversion;  Check: myFoundWin64Python;
Source: {#MyWin64PythonDir}\DLLs\ChronoEngine_FEM.dll; DestDir: {code:myGetPathWin64PythonDLLs};  Flags: ignoreversion;  Check: myFoundWin64Python;
Source: {#MyWin64PythonDir}\DLLs\Irrlicht.dll; DestDir: {code:myGetPathWin64PythonDLLs};  Flags: ignoreversion;  Check: myFoundWin64Python;
Source: {#MyWin64PythonDir}\lib\ChronoEngine_PYTHON_core.py; DestDir: {code:myGetPathWin64PythonLib};  Flags: ignoreversion;  Check: myFoundWin64Python;
Source: {#MyWin64PythonDir}\lib\ChronoEngine_PYTHON_postprocess.py; DestDir: {code:myGetPathWin64PythonLib};  Flags: ignoreversion;  Check: myFoundWin64Python;
Source: {#MyWin64PythonDir}\lib\ChronoEngine_PYTHON_irrlicht.py; DestDir: {code:myGetPathWin64PythonLib};  Flags: ignoreversion;  Check: myFoundWin64Python;
Source: {#MyWin64PythonDir}\lib\ChronoEngine_PYTHON_fem.py; DestDir: {code:myGetPathWin64PythonLib};  Flags: ignoreversion;  Check: myFoundWin64Python;

[Icons]
Name: "{group}\Getting started"; Filename: "http://www.chronoengine.info"
Name: "{group}\Demos"; Filename: "{app}\python"
Name: "{group}\Uninstall"; Filename: "{uninstallexe}"

[Code]
var
  DataDirPage: TInputDirWizardPage;
  mFoundWin32Python: Integer;
  mPathWin32Python: String;
  mPathWin32PythonLib: String;
  mPathWin32PythonDLLs: String;
  mFoundWin64Python: Integer;
  mPathWin64Python: String;
  mPathWin64PythonLib: String;
  mPathWin64PythonDLLs: String;

function myFoundWin32Python: Boolean;
begin
  Result := mFoundWin32Python =1;
end;
function myGetPathWin32Python(Param: String): String;
begin
  Result := mPathWin32Python;
end;
function myGetPathWin32PythonLib(Param: String): String;
begin
  Result := mPathWin32PythonLib;
end;
function myGetPathWin32PythonDLLs(Param: String): String;
begin
  Result := mPathWin32PythonDLLs;
end;
function myFoundWin64Python: Boolean;
begin
  Result := mFoundWin64Python =1;
end;
function myGetPathWin64Python(Param: String): String;
begin
  Result := mPathWin64Python;
end;
function myGetPathWin64PythonLib(Param: String): String;
begin
  Result := mPathWin64PythonLib;
end;
function myGetPathWin64PythonDLLs(Param: String): String;
begin
  Result := mPathWin64PythonDLLs;
end;

procedure InitializeWizard;
var
  mTitlePythondir: String;
  mallDirPython: String;
  mCut: Integer;
  myvers: String;
begin

  // CHECK PYTHON INSTALLATION
  mFoundWin32Python := 0;
  mFoundWin64Python := 0;

  myvers := '{#MyPythonVers}';

  if (IsWin64) then
  begin
    // CASE OF 64 BIT PLATFORM

        // find 64 bit python:
    if RegQueryStringValue(HKEY_LOCAL_MACHINE,
                    'SOFTWARE\Python\PythonCore\' +  myvers+ '\InstallPath',
                    '',
                    mallDirPython) then
    begin
          MsgBox('FOUND! 64bit !'#13#13 + mallDirPython, mbError, MB_OK);
          mPathWin64Python := mallDirPython;
          mFoundWin64Python := 1;
    end

        // find 32 bit python:
    if RegQueryStringValue(HKEY_LOCAL_MACHINE,
                    'SOFTWARE\Wow6432Node\Python\PythonCore\' +  myvers+ '\InstallPath',
                    '',
                    mallDirPython) then
    begin
          mPathWin32Python := mallDirPython;
          mFoundWin32Python := 1;
    end

  end
  else
  begin
    // CASE OF 32 BIT PLATFORM

    // find 32 bit python:
    if RegQueryStringValue(HKEY_LOCAL_MACHINE,
                    'SOFTWARE\Python\PythonCore\' +  myvers+ '\InstallPath',
                    '',
                    mallDirPython) then
    begin
          mPathWin32Python := mallDirPython;
          mFoundWin32Python := 1;
    end

  end

  mPathWin32PythonDLLs := AddBackslash(mPathWin32Python) + 'DLLs';
  mPathWin32PythonLib  := AddBackslash(mPathWin32Python) + 'Lib';
  mPathWin64PythonDLLs := AddBackslash(mPathWin64Python) + 'DLLs';
  mPathWin64PythonLib  := AddBackslash(mPathWin64Python) + 'Lib';

  { Create the pages }

  //
  // Select directory dialog for plugin
  //
  if mFoundWin64Python = 1 then begin mTitlePythondir := 'A copy of 64bit Python has been automatically detected, installed in this directory.'#13+
                                   'Do NOT modify the installation path unless you know what you are doing:'#13+
                                   'the Chrono::Engine module works only if installed in the proper Python directory!';
                    end else begin mTitlePythondir := 'The installation directory of Python has NOT been automatically found!. '#13+
                                   'Nevertheless, you can still go on with the installation, something went'#13+
                                   'wrong with your registry keys. Note: set this directory so that it is the'#13+
                                   'directory where python.exe file is installed, for Win64 bit'#13+
                                   'for example  C:\Python33 '; end

  DataDirPage := CreateInputDirPage(wpWelcome,
    'Check Python directory', 'Where is your Python (version ' +  myvers + ' or following, 64bit) directory?',
    mTitlePythondir,
    False, '');
  DataDirPage.Add('');
  DataDirPage.Values[0] := Format('%s\', [mPathWin64Python] );

end;

function NextButtonClick(CurPageID: Integer): Boolean;
var
  I: Integer;
  mfilesize: Integer;
begin

  //
  // After the user has entered data...
  //
  if CurPageID = wpWelcome then begin

   //   if ((mFoundWin32Python = 0) and (mFoundWin64Python = 0) ) then begin
   //     mPathWin64Python := '{#MyWin64PythonDir}';
   //     MsgBox('WARNING!'#13#13+
   //            'The installer was not able to detect Python (version' +  '{#MyPythonVers}' + ') '+
   //            'on your system.'#13#13+
   //            'Maybe your Python (version' +  '{#MyPythonVers}' + ') is not yet installed, or not properly installed?'#13+
   //            '(If so,please install/reinstall Python 64 bit before installing this plug-in).', mbError, MB_OK);
   //  end;
   //
      Result := True;

  //
  // After the user has choosen python directory..
  //
  end else if CurPageID = DataDirPage.ID then begin

      mPathWin64Python     := DataDirPage.Values[0];
      mPathWin64PythonDLLs := AddBackslash(mPathWin64Python) + 'DLLs';
      mPathWin64PythonLib  := AddBackslash(mPathWin64Python) + 'Lib';

      if FileOrDirExists(mPathWin64Python) and FileOrDirExists(mPathWin64PythonDLLs) and FileOrDirExists(mPathWin64PythonLib) then begin
        Result := True;
        mFoundWin64Python :=1;
      end else begin
        MsgBox('Error. The directory '+ mPathWin64Python + ' does not exist', mbError, MB_OK);
        Result := False;
      end

  end else
      Result := True;
end;

function ShouldSkipPage(PageID: Integer): Boolean;
begin
  Result := False;

  { Skip pages that shouldn't be shown }

  if (PageID = wpSelectDir) then
    Result := True

  if ((PageId = DataDirPage.ID) and ((mFoundWin64Python =1) or (mFoundWin32Python =1)))  then
    Result := True
end;

function UpdateReadyMemo(Space, NewLine, MemoUserInfoInfo, MemoDirInfo, MemoTypeInfo,
  MemoComponentsInfo, MemoGroupInfo, MemoTasksInfo: String): String;
var
  S: String;
begin
  { Fill the 'Ready Memo' with the normal settings and the custom settings }
  S := '';

  if (mFoundWin32Python = 1) then begin
    S := S + 'A Win32 Python has been detected in:' + NewLine;
    S := S + Space + mPathWin32Python + NewLine;
    S := S + 'but the Chrono::Engine 32 bit module is NOT INCLUDED in this installer AND CANNOT BE INSTALLED!' + NewLine;
    //S := S + Space + mPathWin32PythonDLLs + NewLine;
    //S := S + Space + mPathWin32PythonLib + NewLine;
  end

  if ((mFoundWin64Python = 1) and (mFoundWin32Python = 0)) then begin
    S := S + 'A Win64 Python has been detected in:' + NewLine;
    S := S + Space + mPathWin64Python + NewLine;
    S := S + 'so the Chrono::Engine 64 bit module will be installed in:' + NewLine;
    //S := S + 'so the Chrono::Engine 64 bit module will be installed in:' + NewLine;
    S := S + Space + mPathWin64PythonDLLs + NewLine;
    S := S + Space + mPathWin64PythonLib + NewLine;
  end

  if ((mFoundWin64Python = 0) and  (mFoundWin32Python = 0)) then begin
    S := S + 'Neither Win32 nor Win64 Python (version' +  '{#MyPythonVers}' + ') has been detected.' + NewLine;
    S := S + 'Chrono::Engine module CANNOT BE INSTALLED!' + NewLine;
  end

  Result := S;
end;

//function CheckSerial(Serial: String): Boolean;
//begin
//   Result:=True;
//end;


Corrected urls on teh finish page.

Corrected urls on teh finish page.

// RubyInstaller Inno Setup GUI Customizations
//
// Copyright (c) 2009 Jon Maken
// Revision: 11/23/2009 3:35:36 PM
// License: MIT

var
  PathChkBox, PathExtChkBox: TCheckBox;

function IsAssociated(): Boolean;
begin
  Result := PathExtChkBox.Checked;
end;

function IsModifyPath(): Boolean;
begin
  Result := PathChkBox.Checked;
end;

procedure ParseSilentTasks();
var
  I, N: Integer;
  Param: String;
  Tasks: TStringList;
begin
  {* parse command line args for silent install tasks *}
  for I := 0 to ParamCount do
  begin
    Param := AnsiUppercase(ParamStr(I));
    if Pos('/TASKS', Param) <> 0 then
    begin
      Param := Trim(Copy(Param, Pos('=', Param) + 1, Length(Param)));
      try
        // TODO check for too many tasks to prevent overflow??
        Tasks := StrToList(Param, ',');
        for N := 0 to Tasks.Count - 1 do
          case Trim(Tasks.Strings[N]) of
            'MODPATH': PathChkBox.State := cbChecked;
          end;
      finally
        Tasks.Free;
      end;
    end;
  end;
end;

procedure URLText_OnClick(Sender: TObject);
var
  ErrorCode: Integer;
begin
  if Sender is TNewStaticText then
    ShellExec('open', TNewStaticText(Sender).Caption, '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
end;

procedure InitializeWizard;
var
  Page: TWizardPage;
  HostPage: TNewNotebookPage;
  URLText, TmpLabel: TNewStaticText;
begin

  {* Path and file association task check boxes *}

  Page := PageFromID(wpSelectDir);

  PathChkBox := TCheckBox.Create(Page);
  PathChkBox.Parent := Page.Surface;
  PathChkBox.State := cbChecked;
  PathChkBox.Caption := 'Add executables for Ruby, Git and DevKit to the PATH ';
  PathChkBox.Alignment := taRightJustify;
  PathChkBox.Top := ScaleY(95);
  PathChkBox.Left := ScaleX(18);
  PathChkBox.Width := Page.SurfaceWidth;
  PathChkBox.Height := ScaleY(17);

  ParseSilentTasks;

  {* FIXME: Labels and links back to RailsInstaller project pages *}

  HostPage := WizardForm.FinishedPage;

  TmpLabel := TNewStaticText.Create(HostPage);
  TmpLabel.Parent := HostPage;
  TmpLabel.Top := ScaleY(180);
  TmpLabel.Left := ScaleX(176);
  TmpLabel.AutoSize := True;
  TmpLabel.Caption := 'Web Site:';

  URLText := TNewStaticText.Create(HostPage);
  URLText.Parent := HostPage;
  URLText.Top := TmpLabel.Top;
  URLText.Left := TmpLabel.Left + TmpLabel.Width + ScaleX(4);
  URLText.AutoSize := True;
  URLText.Caption := 'http://railsinstaller.org';
  URLText.Cursor := crHand;
  URLText.Font.Color := clBlue;
  URLText.OnClick := @URLText_OnClick;

  TmpLabel := TNewStaticText.Create(HostPage);
  TmpLabel.Parent := HostPage;
  TmpLabel.Top := ScaleY(196);
  TmpLabel.Left := ScaleX(176);
  TmpLabel.AutoSize := True;
  TmpLabel.Caption := 'Support group:';

  URLText := TNewStaticText.Create(HostPage);
  URLText.Parent := HostPage;
  URLText.Top := TmpLabel.Top;
  URLText.Left := TmpLabel.Left + TmpLabel.Width + ScaleX(4);
  URLText.AutoSize := True;
  URLText.Caption := 'http://groups.google.com/group/railsinstaller';
  URLText.Cursor := crHand;
  URLText.Font.Color := clBlue;
  URLText.OnClick := @URLText_OnClick;

  TmpLabel := TNewStaticText.Create(HostPage);
  TmpLabel.Parent := HostPage;
  TmpLabel.Top := ScaleY(212);
  TmpLabel.Left := ScaleX(176);
  TmpLabel.AutoSize := True;
  TmpLabel.Caption := 'Wiki:';

  URLText := TNewStaticText.Create(HostPage);
  URLText.Parent := HostPage;
  URLText.Top := TmpLabel.Top;
  URLText.Left := TmpLabel.Left + TmpLabel.Width + ScaleX(4);
  URLText.AutoSize := True;
  URLText.Caption := 'http://wiki.github.com/wayneeseguin/railsinstaller';
  URLText.Cursor := crHand;
  URLText.Font.Color := clBlue;
  URLText.OnClick := @URLText_OnClick;

  URLText := TNewStaticText.Create(HostPage);
  URLText.Parent := HostPage;
  URLText.Top := TmpLabel.Top;
  URLText.Left := TmpLabel.Left + TmpLabel.Width + ScaleX(4);
  URLText.AutoSize := True;
  URLText.Caption := 'http://webchat.freenode.net/?channels=railsinstaller,rubyinstaller,rvm';
  URLText.Cursor := crHand;
  URLText.Font.Color := clBlue;
  URLText.OnClick := @URLText_OnClick;

end;

procedure CurPageChanged(CurPageID: Integer);
begin
  if CurPageID = wpSelectDir then
    WizardForm.NextButton.Caption := '&Install';
end;

// RubyInstaller Inno Setup GUI Customizations
//
// Copyright (c) 2009 Jon Maken
// Revision: 11/23/2009 3:35:36 PM
// License: MIT

var
  PathChkBox, PathExtChkBox: TCheckBox;

function IsAssociated(): Boolean;
begin
  Result := PathExtChkBox.Checked;
end;

function IsModifyPath(): Boolean;
begin
  Result := PathChkBox.Checked;
end;

procedure ParseSilentTasks();
var
  I, N: Integer;
  Param: String;
  Tasks: TStringList;
begin
  {* parse command line args for silent install tasks *}
  for I := 0 to ParamCount do
  begin
    Param := AnsiUppercase(ParamStr(I));
    if Pos('/TASKS', Param) <> 0 then
    begin
      Param := Trim(Copy(Param, Pos('=', Param) + 1, Length(Param)));
      try
        // TODO check for too many tasks to prevent overflow??
        Tasks := StrToList(Param, ',');
        for N := 0 to Tasks.Count - 1 do
          case Trim(Tasks.Strings[N]) of
            'MODPATH': PathChkBox.State := cbChecked;
          end;
      finally
        Tasks.Free;
      end;
    end;
  end;
end;

procedure URLText_OnClick(Sender: TObject);
var
  ErrorCode: Integer;
begin
  if Sender is TNewStaticText then
    ShellExec('open', TNewStaticText(Sender).Caption, '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
end;

procedure InitializeWizard;
var
  Page: TWizardPage;
  HostPage: TNewNotebookPage;
  URLText, TmpLabel: TNewStaticText;
begin

  {* Path and file association task check boxes *}

  Page := PageFromID(wpSelectDir);

  PathChkBox := TCheckBox.Create(Page);
  PathChkBox.Parent := Page.Surface;
  PathChkBox.State := cbChecked;
  PathChkBox.Caption := 'Add executables for Ruby, Git and DevKit to the PATH ';
  PathChkBox.Alignment := taRightJustify;
  PathChkBox.Top := ScaleY(95);
  PathChkBox.Left := ScaleX(18);
  PathChkBox.Width := Page.SurfaceWidth;
  PathChkBox.Height := ScaleY(17);

  ParseSilentTasks;

  {* FIXME: Labels and links back to RailsInstaller project pages *}

  HostPage := WizardForm.FinishedPage;

  TmpLabel := TNewStaticText.Create(HostPage);
  TmpLabel.Parent := HostPage;
  TmpLabel.Top := ScaleY(180);
  TmpLabel.Left := ScaleX(176);
  TmpLabel.AutoSize := True;
  TmpLabel.Caption := 'Web Site:';

  URLText := TNewStaticText.Create(HostPage);
  URLText.Parent := HostPage;
  URLText.Top := TmpLabel.Top;
  URLText.Left := TmpLabel.Left + TmpLabel.Width + ScaleX(4);
  URLText.AutoSize := True;
  URLText.Caption := 'http://rubyinstaller.org';
  URLText.Cursor := crHand;
  URLText.Font.Color := clBlue;
  URLText.OnClick := @URLText_OnClick;

  TmpLabel := TNewStaticText.Create(HostPage);
  TmpLabel.Parent := HostPage;
  TmpLabel.Top := ScaleY(196);
  TmpLabel.Left := ScaleX(176);
  TmpLabel.AutoSize := True;
  TmpLabel.Caption := 'Support group:';

  URLText := TNewStaticText.Create(HostPage);
  URLText.Parent := HostPage;
  URLText.Top := TmpLabel.Top;
  URLText.Left := TmpLabel.Left + TmpLabel.Width + ScaleX(4);
  URLText.AutoSize := True;
  URLText.Caption := 'http://groups.google.com/group/rubyinstaller';
  URLText.Cursor := crHand;
  URLText.Font.Color := clBlue;
  URLText.OnClick := @URLText_OnClick;

  TmpLabel := TNewStaticText.Create(HostPage);
  TmpLabel.Parent := HostPage;
  TmpLabel.Top := ScaleY(212);
  TmpLabel.Left := ScaleX(176);
  TmpLabel.AutoSize := True;
  TmpLabel.Caption := 'Wiki:';

  URLText := TNewStaticText.Create(HostPage);
  URLText.Parent := HostPage;
  URLText.Top := TmpLabel.Top;
  URLText.Left := TmpLabel.Left + TmpLabel.Width + ScaleX(4);
  URLText.AutoSize := True;
  URLText.Caption := 'http://wiki.github.com/wayneeseguin/railsinstaller';
  URLText.Cursor := crHand;
  URLText.Font.Color := clBlue;
  URLText.OnClick := @URLText_OnClick;

  URLText := TNewStaticText.Create(HostPage);
  URLText.Parent := HostPage;
  URLText.Top := TmpLabel.Top;
  URLText.Left := TmpLabel.Left + TmpLabel.Width + ScaleX(4);
  URLText.AutoSize := True;
  URLText.Caption := 'http://webchat.freenode.net/?channels=rubyinstaller,rvm';
  URLText.Cursor := crHand;
  URLText.Font.Color := clBlue;
  URLText.OnClick := @URLText_OnClick;

end;

procedure CurPageChanged(CurPageID: Integer);
begin
  if CurPageID = wpSelectDir then
    WizardForm.NextButton.Caption := '&Install';
end;


Add win32/README.txt to the Source/ directory that gets installed.

; Basic setup script for the Inno Setep installer builder.  For more
; information on the free installer builder, see www.jrsoftware.org.
;
; This script was contributed by Tim Peters.
; The current version is used with Inno Setup 2.0.19.

[Setup]
AppName=expat
AppId=expat
AppVersion=1.95.6
AppVerName=expat 1.95.6
AppCopyright=Copyright  1998-2002 Thai Open Source Software Center, Clark Cooper, and the Expat maintainers
DefaultDirName={sd}\Expat-1.95.6
AppPublisher=The Expat Developers
AppPublisherURL=http://www.libexpat.org/
AppSupportURL=http://www.libexpat.org/
AppUpdatesURL=http://www.libexpat.org/
UninstallDisplayName=Expat XML Parser (version 1.95.6)
UninstallFilesDir={app}\Uninstall

Compression=bzip/9
SourceDir=..
OutputDir=win32
DisableStartupPrompt=yes
AllowNoIcons=yes
DisableProgramGroupPage=yes
DisableReadyPage=yes

[Files]
CopyMode: alwaysoverwrite; Source: xmlwf\Release\*.exe;        DestDir: "{app}"
CopyMode: alwaysoverwrite; Source: win32\MANIFEST.txt;         DestDir: "{app}"
CopyMode: alwaysoverwrite; Source: Changes;                    DestDir: "{app}"; DestName: Changes.txt
CopyMode: alwaysoverwrite; Source: COPYING;                    DestDir: "{app}"; DestName: COPYING.txt
CopyMode: alwaysoverwrite; Source: README;                     DestDir: "{app}"; DestName: README.txt
CopyMode: alwaysoverwrite; Source: doc\*.html;                 DestDir: "{app}\Doc"
CopyMode: alwaysoverwrite; Source: doc\*.css;                  DestDir: "{app}\Doc"
CopyMode: alwaysoverwrite; Source: doc\*.png;                  DestDir: "{app}\Doc"
CopyMode: alwaysoverwrite; Source: lib\Release\*.dll;          DestDir: "{app}\Libs"
CopyMode: alwaysoverwrite; Source: lib\Release\*.lib;          DestDir: "{app}\Libs"
CopyMode: alwaysoverwrite; Source: lib\Release-w\*.dll;        DestDir: "{app}\Libs"
CopyMode: alwaysoverwrite; Source: lib\Release-w\*.lib;        DestDir: "{app}\Libs"
CopyMode: alwaysoverwrite; Source: lib\Release_static\*.lib;   DestDir: "{app}\StaticLibs"
CopyMode: alwaysoverwrite; Source: lib\Release-w_static\*.lib; DestDir: "{app}\StaticLibs"
CopyMode: alwaysoverwrite; Source: expat.dsw;                  DestDir: "{app}\Source"
CopyMode: alwaysoverwrite; Source: win32\README.txt;           DestDir: "{app}\Source"
CopyMode: alwaysoverwrite; Source: bcb5\*.*;                   DestDir: "{app}\Source\bcb5"
CopyMode: alwaysoverwrite; Source: lib\*.c;                    DestDir: "{app}\Source\lib"
CopyMode: alwaysoverwrite; Source: lib\*.h;                    DestDir: "{app}\Source\lib"
CopyMode: alwaysoverwrite; Source: lib\*.def;                  DestDir: "{app}\Source\lib"
CopyMode: alwaysoverwrite; Source: lib\*.dsp;                  DestDir: "{app}\Source\lib"
CopyMode: alwaysoverwrite; Source: examples\*.c;               DestDir: "{app}\Source\examples"
CopyMode: alwaysoverwrite; Source: examples\*.dsp;             DestDir: "{app}\Source\examples"
CopyMode: alwaysoverwrite; Source: tests\*.c;                  DestDir: "{app}\Source\tests"
CopyMode: alwaysoverwrite; Source: tests\*.h;                  DestDir: "{app}\Source\tests"
CopyMode: alwaysoverwrite; Source: tests\README.txt;           DestDir: "{app}\Source\tests"
CopyMode: alwaysoverwrite; Source: xmlwf\*.c*;                 DestDir: "{app}\Source\xmlwf"
CopyMode: alwaysoverwrite; Source: xmlwf\*.h;                  DestDir: "{app}\Source\xmlwf"
CopyMode: alwaysoverwrite; Source: xmlwf\*.dsp;                DestDir: "{app}\Source\xmlwf"

[Messages]
WelcomeLabel1=Welcome to the Expat XML Parser Setup Wizard
WelcomeLabel2=This will install [name/ver] on your computer.%n%nExpat is an XML parser with a C-language API, and is primarily made available to allow developers to build applications which use XML using a portable API and fast implementation.%n%nIt is strongly recommended that you close all other applications you have running before continuing. This will help prevent any conflicts during the installation process.

; Basic setup script for the Inno Setep installer builder.  For more
; information on the free installer builder, see www.jrsoftware.org.
;
; This script was contributed by Tim Peters.
; The current version is used with Inno Setup 2.0.19.

[Setup]
AppName=expat
AppId=expat
AppVersion=1.95.6
AppVerName=expat 1.95.6
AppCopyright=Copyright  1998-2002 Thai Open Source Software Center, Clark Cooper, and the Expat maintainers
DefaultDirName={sd}\Expat-1.95.6
AppPublisher=The Expat Developers
AppPublisherURL=http://www.libexpat.org/
AppSupportURL=http://www.libexpat.org/
AppUpdatesURL=http://www.libexpat.org/
UninstallDisplayName=Expat XML Parser (version 1.95.6)
UninstallFilesDir={app}\Uninstall

Compression=bzip/9
SourceDir=..
OutputDir=win32
DisableStartupPrompt=yes
AllowNoIcons=yes
DisableProgramGroupPage=yes
DisableReadyPage=yes

[Files]
CopyMode: alwaysoverwrite; Source: xmlwf\Release\*.exe;        DestDir: "{app}"
CopyMode: alwaysoverwrite; Source: win32\MANIFEST.txt;         DestDir: "{app}"
CopyMode: alwaysoverwrite; Source: Changes;                    DestDir: "{app}"; DestName: Changes.txt
CopyMode: alwaysoverwrite; Source: COPYING;                    DestDir: "{app}"; DestName: COPYING.txt
CopyMode: alwaysoverwrite; Source: README;                     DestDir: "{app}"; DestName: README.txt
CopyMode: alwaysoverwrite; Source: doc\*.html;                 DestDir: "{app}\Doc"
CopyMode: alwaysoverwrite; Source: doc\*.css;                  DestDir: "{app}\Doc"
CopyMode: alwaysoverwrite; Source: doc\*.png;                  DestDir: "{app}\Doc"
CopyMode: alwaysoverwrite; Source: lib\Release\*.dll;          DestDir: "{app}\Libs"
CopyMode: alwaysoverwrite; Source: lib\Release\*.lib;          DestDir: "{app}\Libs"
CopyMode: alwaysoverwrite; Source: lib\Release-w\*.dll;        DestDir: "{app}\Libs"
CopyMode: alwaysoverwrite; Source: lib\Release-w\*.lib;        DestDir: "{app}\Libs"
CopyMode: alwaysoverwrite; Source: lib\Release_static\*.lib;   DestDir: "{app}\StaticLibs"
CopyMode: alwaysoverwrite; Source: lib\Release-w_static\*.lib; DestDir: "{app}\StaticLibs"
CopyMode: alwaysoverwrite; Source: expat.dsw;                  DestDir: "{app}\Source"
CopyMode: alwaysoverwrite; Source: bcb5\*.*;                   DestDir: "{app}\Source\bcb5"
CopyMode: alwaysoverwrite; Source: lib\*.c;                    DestDir: "{app}\Source\lib"
CopyMode: alwaysoverwrite; Source: lib\*.h;                    DestDir: "{app}\Source\lib"
CopyMode: alwaysoverwrite; Source: lib\*.def;                  DestDir: "{app}\Source\lib"
CopyMode: alwaysoverwrite; Source: lib\*.dsp;                  DestDir: "{app}\Source\lib"
CopyMode: alwaysoverwrite; Source: examples\*.c;               DestDir: "{app}\Source\examples"
CopyMode: alwaysoverwrite; Source: examples\*.dsp;             DestDir: "{app}\Source\examples"
CopyMode: alwaysoverwrite; Source: tests\*.c;                  DestDir: "{app}\Source\tests"
CopyMode: alwaysoverwrite; Source: tests\*.h;                  DestDir: "{app}\Source\tests"
CopyMode: alwaysoverwrite; Source: tests\README.txt;           DestDir: "{app}\Source\tests"
CopyMode: alwaysoverwrite; Source: xmlwf\*.c*;                 DestDir: "{app}\Source\xmlwf"
CopyMode: alwaysoverwrite; Source: xmlwf\*.h;                  DestDir: "{app}\Source\xmlwf"
CopyMode: alwaysoverwrite; Source: xmlwf\*.dsp;                DestDir: "{app}\Source\xmlwf"

[Messages]
WelcomeLabel1=Welcome to the Expat XML Parser Setup Wizard
WelcomeLabel2=This will install [name/ver] on your computer.%n%nExpat is an XML parser with a C-language API, and is primarily made available to allow developers to build applications which use XML using a portable API and fast implementation.%n%nIt is strongly recommended that you close all other applications you have running before continuing. This will help prevent any conflicts during the installation process.


Update installer script.

Update installer script.

[Tasks]
Name: desktopicon; Description: Create a desktop icon; Flags: unchecked
Name: associate; Description: Associate with Dehacked patch files

[Files]
Source: .\build\exe.win-amd64-3.9\*.*; DestDir: {app}; Flags: recursesubdirs createallsubdirs
Source: .\fonts\dejavu-sans-mono\DejaVuSansMono.ttf; DestDir: {autofonts}; Flags: onlyifdoesntexist uninsneveruninstall; FontInstall: DejaVu Sans Mono
Source: .\fonts\dejavu-sans-mono\DejaVuSansMono-Bold.ttf; DestDir: {autofonts}; Flags: onlyifdoesntexist uninsneveruninstall; FontInstall: DejaVu Sans Mono Bold

[Icons]
Name: {group}\WhackEd4; Filename: {app}\whacked4.exe; WorkingDir: {app}; IconFilename: {app}\res\icon-hatchet.ico; IconIndex: 0
Name: {userdesktop}\WhackEd4; Filename: {app}\whacked4.exe; WorkingDir: {app}; IconFilename: {app}\res\icon-hatchet.ico; IconIndex: 0; Tasks: " desktopicon"
Name: {group}\{cm:UninstallProgram, WhackEd4}; Filename: {uninstallexe}

[Setup]
InternalCompressLevel=ultra64
SolidCompression=true
AppName=WhackEd4
AppVerName=WhackEd4 1.3.0 beta
DefaultDirName={autopf}\WhackEd4
AlwaysUsePersonalGroup=false
ShowLanguageDialog=no
AppVersion=1.3.0 beta
UninstallDisplayIcon={app}\whacked4.exe
UninstallDisplayName=WhackEd4
AppendDefaultGroupName=true
DefaultGroupName=WhackEd4
Compression=lzma2/ultra64
OutputDir=.
SourceDir=.
OutputBaseFilename=whacked4-setup-1.3.0-beta
AllowNoIcons=true
PrivilegesRequired=admin
ChangesAssociations=true
InfoBeforeFile=
LicenseFile=LICENSE
FlatComponentsList=true
UninstallLogMode=overwrite
LanguageDetectionMethod=none
WizardImageStretch=false
RestartIfNeededByRun=false
AppID={{A8A56AC6-E82B-49AD-9093-5AC204830F89}

[Run]
Filename: {app}\whacked4.exe; WorkingDir: {app}; Description: Run WhackEd4; Flags: nowait postinstall hidewizard skipifsilent

[InstallDelete]
Name: {app}\cfg\tables_mbf_beta.json; Type: files

[UninstallDelete]
Name: {app}\res; Type: filesandordirs
Name: {app}\cfg; Type: filesandordirs
Name: {app}\*.*; Type: files
Name: {app}; Type: dirifempty
Name: {userappdata}\whacked4; Type: filesandordirs

[Registry]
Root: HKCR; SubKey: "WhackEd4"; ValueType: String; ValueName: ""; ValueData: "WhackEd4 patch file"; Flags: uninsdeletekey; Tasks: associate
Root: HKCR; Subkey: "WhackEd4\DefaultIcon"; ValueType: String; ValueName: ""; ValueData: "{app}\res\icon-document.ico,0"; Flags: uninsdeletekey; Tasks: associate

Root: HKCR; SubKey: "WhackEd4\Shell\Open\Command"; ValueType: String; ValueName: ""; ValueData: """{app}\whacked4.exe"" -workdir ""{app}"" -open ""%1"""; Flags: uninsdeletekey; Tasks: associate

Root: HKCR; SubKey: ".deh"; ValueType: String; ValueName: ""; ValueData: "WhackEd4"; Flags: uninsdeletekey; Tasks: associate
Root: HKCR; SubKey: ".bex"; ValueType: String; ValueName: ""; ValueData: "WhackEd4"; Flags: uninsdeletekey; Tasks: associate

[Tasks]
Name: desktopicon; Description: Create a desktop icon; Flags: unchecked
Name: associate; Description: Associate with Dehacked patch files

[Files]
Source: .\build\exe.win-amd64-3.9\*.*; DestDir: {app}; Flags: recursesubdirs createallsubdirs
Source: .\fonts\dejavu-sans-mono\DejaVuSansMono.ttf; DestDir: {fonts}; Flags: onlyifdoesntexist uninsneveruninstall; FontInstall: DejaVu Sans Mono
Source: .\fonts\dejavu-sans-mono\DejaVuSansMono-Bold.ttf; DestDir: {fonts}; Flags: onlyifdoesntexist uninsneveruninstall; FontInstall: DejaVu Sans Mono Bold

[Icons]
Name: {group}\WhackEd4; Filename: {app}\whacked4.exe; WorkingDir: {app}; IconFilename: {app}\res\icon-hatchet.ico; IconIndex: 0
Name: {userdesktop}\WhackEd4; Filename: {app}\whacked4.exe; WorkingDir: {app}; IconFilename: {app}\res\icon-hatchet.ico; IconIndex: 0; Tasks: " desktopicon"
Name: {group}\{cm:UninstallProgram, WhackEd4}; Filename: {uninstallexe}

[Setup]
InternalCompressLevel=ultra64
SolidCompression=true
AppName=WhackEd4
AppVerName=WhackEd4 1.3.0 beta
DefaultDirName={pf}\WhackEd4
AlwaysUsePersonalGroup=false
ShowLanguageDialog=no
AppVersion=1.3.0 beta
UninstallDisplayIcon={app}\whacked4.exe
UninstallDisplayName=WhackEd4
AppendDefaultGroupName=true
DefaultGroupName=WhackEd4
Compression=lzma2/ultra64
OutputDir=.
SourceDir=.
OutputBaseFilename=whacked4-setup-1.3.0-beta
AllowNoIcons=true
PrivilegesRequired=admin
ChangesAssociations=true
InfoBeforeFile=
LicenseFile=LICENSE
FlatComponentsList=true
UninstallLogMode=overwrite
LanguageDetectionMethod=none
WizardImageStretch=false
RestartIfNeededByRun=false
AppID={{A8A56AC6-E82B-49AD-9093-5AC204830F89}

[Run]
Filename: {app}\whacked4.exe; WorkingDir: {app}; Description: Run WhackEd4; Flags: nowait postinstall hidewizard skipifsilent

[InstallDelete]
Name: {app}\cfg\tables_mbf_beta.json; Type: files

[UninstallDelete]
Name: {app}\res; Type: filesandordirs
Name: {app}\cfg; Type: filesandordirs
Name: {app}\*.*; Type: files
Name: {app}; Type: dirifempty
Name: {userappdata}\whacked4; Type: filesandordirs

[Registry]
Root: HKCR; SubKey: "WhackEd4"; ValueType: String; ValueName: ""; ValueData: "WhackEd4 patch file"; Flags: uninsdeletekey; Tasks: associate
Root: HKCR; Subkey: "WhackEd4\DefaultIcon"; ValueType: String; ValueName: ""; ValueData: "{app}\res\icon-document.ico,0"; Flags: uninsdeletekey; Tasks: associate

Root: HKCR; SubKey: "WhackEd4\Shell\Open\Command"; ValueType: String; ValueName: ""; ValueData: """{app}\whacked4.exe"" -workdir ""{app}"" -open ""%1"""; Flags: uninsdeletekey; Tasks: associate

Root: HKCR; SubKey: ".deh"; ValueType: String; ValueName: ""; ValueData: "WhackEd4"; Flags: uninsdeletekey; Tasks: associate
Root: HKCR; SubKey: ".bex"; ValueType: String; ValueName: ""; ValueData: "WhackEd4"; Flags: uninsdeletekey; Tasks: associate


Windows installer improvements:      - desktop icon      - quick launch icon      - context menu entry

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

[Setup]
AppCopyright= Akos Gyimesi, 2009
AppName=StupidGit
AppVerName=0.1
PrivilegesRequired=none
DefaultDirName={pf}\StupidGit
DefaultGroupName=StupidGit

[Files]
Source: dist\bz2.pyd; DestDir: {app}
Source: dist\library.zip; DestDir: {app}
Source: dist\python26.dll; DestDir: {app}
Source: dist\select.pyd; DestDir: {app}
Source: dist\stupidgit.exe; DestDir: {app}
Source: dist\unicodedata.pyd; DestDir: {app}
Source: dist\w9xpopen.exe; DestDir: {app}
Source: dist\wx._controls_.pyd; DestDir: {app}
Source: dist\wx._core_.pyd; DestDir: {app}
Source: dist\wx._gdi_.pyd; DestDir: {app}
Source: dist\wx._html.pyd; DestDir: {app}
Source: dist\wx._misc_.pyd; DestDir: {app}
Source: dist\wx._stc.pyd; DestDir: {app}
Source: dist\wx._windows_.pyd; DestDir: {app}
Source: dist\wxbase28uh_net_vc.dll; DestDir: {app}
Source: dist\wxbase28uh_vc.dll; DestDir: {app}
Source: dist\wxmsw28uh_adv_vc.dll; DestDir: {app}
Source: dist\wxmsw28uh_core_vc.dll; DestDir: {app}
Source: dist\wxmsw28uh_html_vc.dll; DestDir: {app}
Source: dist\wxmsw28uh_stc_vc.dll; DestDir: {app}

[Icons]
Name: {group}\StupidGit; Filename: {app}\stupidgit.exe; WorkingDir: {app}; IconIndex: 0
Name: {group}\{cm:UninstallProgram,StupidGit}; Filename: {uninstallexe}
Name: {userdesktop}\StupidGit; Filename: {app}\stupidgit.exe; Tasks: desktopicon; WorkingDir: {app}; IconIndex: 0
Name: {userappdata}\Microsoft\Internet Explorer\Quick Launch\StupidGit; Filename: {app}\stupidgit.exe; Tasks: quicklaunchicon; WorkingDir: {app}; IconIndex: 0

[Tasks]
Name: desktopicon; Description: {cm:CreateDesktopIcon}; GroupDescription: {cm:AdditionalIcons}; Flags: unchecked
Name: quicklaunchicon; Description: {cm:CreateQuickLaunchIcon}; GroupDescription: {cm:AdditionalIcons}; Flags: unchecked
Name: contextmenu; Description: "Add StupidGit to context menu"; GroupDescription: "Windows Explorer integration";

[Code]
procedure CurStepChanged(CurStep: TSetupStep);
begin
    if (CurStep = ssPostInstall) and IsTaskSelected('contextmenu') then
    begin
      RegWriteStringValue(HKCR, 'Directory\shell\StupidGit\command', '', '"' + ExpandConstant('{app}') + '\stupidgit.exe" "%1"');
    end;
end;

procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
    if CurUninstallStep = usUninstall then
    begin
        if RegKeyExists(HKCR, 'Directory\shell\StupidGit') then
        begin
          RegDeleteKeyIncludingSubkeys(HKCR, 'Directory\shell\StupidGit');
        end;
    end;
end;


delete script renamed from stop

delete script renamed from stop

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

#define MyAppName "Boot2Docker"
#define MyAppVersion "0.1"
#define MyAppPublisher "Boot2Docker"
#define MyAppURL "http://boot2docker.io"

[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={{05BD04E9-4AB5-46AC-891E-60EA8FD57D56}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
ArchitecturesAllowed=x64
ArchitecturesInstallIn64BitMode=x64
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName=Boot 2 Docker
InfoBeforeFile=C:\Users\svend_000\windows-installer\LICENSE
OutputBaseFilename=boot2docker-install
Compression=lzma
SolidCompression=yes
WizardImageFile=logo-docker-side.bmp
WizardSmallImageFile=logo-docker-small.bmp

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

[Files]
Source: "C:\Users\svend_000\windows-installer\Boot2Docker\boot2docker.iso"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\svend_000\windows-installer\Boot2Docker\boot2docker-cli.exe"; DestDir: "{app}"; Flags: ignoreversion
;Source: "C:\Users\svend_000\windows-installer\Boot2Docker\profile"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\svend_000\windows-installer\start.sh"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\svend_000\windows-installer\delete.sh"; DestDir: "{app}"; Flags: ignoreversion

; msys-Git
Source: "C:\Users\svend_000\windows-installer\msys-Git\Git-1.9.0-preview20140217.exe"; DestDir: "{app}"; Flags: ignoreversion

;VirtualBox - 64 bit only
;https://forums.virtualbox.org/viewtopic.php?f=3&t=21127
Source: "C:\Users\svend_000\windows-installer\VirtualBox\VirtualBox-4.3.8-r92456-MultiArch_amd64.msi"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\svend_000\windows-installer\VirtualBox\common.cab"; DestDir: "{app}"; Flags: ignoreversion

; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Icons]
Name: "{group}\{cm:ProgramOnTheWeb,{#MyAppName}}"; Filename: "{#MyAppURL}"
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
Name: "{group}\Boot2Docker Shell"; WorkingDir: "{app}"; Filename: "{app}\start.sh"
Name: "{group}\Boot2Docker Delete"; WorkingDir: "{app}"; Filename: "{app}\delete.sh"
Name: "{group}\MSYS Bash"; Filename: "C:\Program Files (x86)\Git\bin\sh.exe"; Parameters: "--login -i"; Flags: dontcloseonexit

[Run]
; http://unattended.sourceforge.net/installers.php
Description: "Install MSYS-git UNIX-like environment (Required)"; Filename: "{app}\Git-1.9.0-preview20140217.exe"; Flags: postinstall
; Parameters: "/sp- /silent /norestart"
Description: "Install VirtualBox virtualisation (Required)"; Filename: "msiexec"; Parameters: "/i ""{app}\VirtualBox-4.3.8-r92456-MultiArch_amd64.msi"""; Flags: postinstall

[UninstallRun]
Filename: "{app}\delete.sh"

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

#define MyAppName "Boot2Docker"
#define MyAppVersion "0.1"
#define MyAppPublisher "Boot2Docker"
#define MyAppURL "http://boot2docker.io"

[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={{05BD04E9-4AB5-46AC-891E-60EA8FD57D56}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
ArchitecturesAllowed=x64
ArchitecturesInstallIn64BitMode=x64
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName=Boot 2 Docker
InfoBeforeFile=C:\Users\svend_000\windows-installer\LICENSE
OutputBaseFilename=boot2docker-install
Compression=lzma
SolidCompression=yes
WizardImageFile=logo-docker-side.bmp
WizardSmallImageFile=logo-docker-small.bmp

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

[Files]
Source: "C:\Users\svend_000\windows-installer\Boot2Docker\boot2docker.iso"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\svend_000\windows-installer\Boot2Docker\boot2docker-cli.exe"; DestDir: "{app}"; Flags: ignoreversion
;Source: "C:\Users\svend_000\windows-installer\Boot2Docker\profile"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\svend_000\windows-installer\start.sh"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\svend_000\windows-installer\delete.sh"; DestDir: "{app}"; Flags: ignoreversion

; msys-Git
Source: "C:\Users\svend_000\windows-installer\msys-Git\Git-1.9.0-preview20140217.exe"; DestDir: "{app}"; Flags: ignoreversion

;VirtualBox - 64 bit only
;https://forums.virtualbox.org/viewtopic.php?f=3&t=21127
Source: "C:\Users\svend_000\windows-installer\VirtualBox\VirtualBox-4.3.8-r92456-MultiArch_amd64.msi"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\svend_000\windows-installer\VirtualBox\common.cab"; DestDir: "{app}"; Flags: ignoreversion

; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Icons]
Name: "{group}\{cm:ProgramOnTheWeb,{#MyAppName}}"; Filename: "{#MyAppURL}"
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
Name: "{group}\Boot2Docker Shell"; WorkingDir: "{app}"; Filename: "{app}\start.sh"
Name: "{group}\Boot2Docker Delete"; WorkingDir: "{app}"; Filename: "{app}\stop.sh"
Name: "{group}\MSYS Bash"; Filename: "C:\Program Files (x86)\Git\bin\sh.exe"; Parameters: "--login -i"; Flags: dontcloseonexit

[Run]
; http://unattended.sourceforge.net/installers.php
Description: "Install MSYS-git UNIX-like environment (Required)"; Filename: "{app}\Git-1.9.0-preview20140217.exe"; Flags: postinstall
; Parameters: "/sp- /silent /norestart"
Description: "Install VirtualBox virtualisation (Required)"; Filename: "msiexec"; Parameters: "/i ""{app}\VirtualBox-4.3.8-r92456-MultiArch_amd64.msi"""; Flags: postinstall

[UninstallRun]
Filename: "{app}\delete.sh"


Add more meta-data to the Windows installer executable

On Windows, this makes the detailed file properties dialog show the file
version and copyright information also for the Windows installer
executable. Previously only the git-lfs executables had this information.

#define MyAppName "Git LFS"

; Arbitrarily choose the x86 executable here as both have the version embedded.
#define MyVersionInfoVersion GetFileVersion("..\..\git-lfs-x86.exe")

; Misuse RemoveFileExt to strip the 4th patch-level version number.
#define MyAppVersion RemoveFileExt(MyVersionInfoVersion)

#define MyAppPublisher "GitHub, Inc."
#define MyAppURL "https://git-lfs.github.com/"
#define MyAppFilePrefix "git-lfs-windows"

[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={{286391DE-F778-44EA-9375-1B21AAA04FF0}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppCopyright=GitHub, Inc. and Git LFS contributors
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
LicenseFile=..\..\LICENSE.md
OutputBaseFilename={#MyAppFilePrefix}-{#MyAppVersion}
OutputDir=..\..\
Compression=lzma
SolidCompression=yes
DefaultDirName={pf}\{#MyAppName}
UsePreviousAppDir=no
DirExistsWarning=no
DisableReadyPage=True
ArchitecturesInstallIn64BitMode=x64
ChangesEnvironment=yes
SetupIconFile=git-lfs-logo.ico
VersionInfoVersion={#MyVersionInfoVersion}
WizardImageFile=git-lfs-wizard-image.bmp
WizardSmallImageFile=git-lfs-logo.bmp

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

[Run]
; Uninstalls the old Git LFS version that used a different installer in a different location:
;  If we don't do this, Git will prefer the old version as it is in the same directory as it.
Filename: "{code:GetExistingGitInstallation}\git-lfs-uninstaller.exe"; Parameters: "/S"; Flags: skipifdoesntexist

[Files]
Source: ..\..\git-lfs-x64.exe; DestDir: "{app}"; Flags: ignoreversion; DestName: "git-lfs.exe"; AfterInstall: InstallGitLFS; Check: Is64BitInstallMode
Source: ..\..\git-lfs-x86.exe; DestDir: "{app}"; Flags: ignoreversion; DestName: "git-lfs.exe"; AfterInstall: InstallGitLFS; Check: not Is64BitInstallMode

[Registry]
Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};{app}"; Check: NeedsAddPath('{app}')
Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType: string; ValueName: "GIT_LFS_PATH"; ValueData: "{app}"

[Code]
// Uses cmd to parse and find the location of Git through the env vars.
// Currently only used to support running the uninstaller for the old Git LFS version.
function GetExistingGitInstallation(Value: string): string;
var
  TmpFileName: String;
  ExecStdOut: AnsiString;
  ResultCode: integer;

begin
  TmpFileName := ExpandConstant('{tmp}') + '\git_location.txt';

  Exec(
    ExpandConstant('{cmd}'),
    '/C "for %i in (git.exe) do @echo. %~$PATH:i > "' + TmpFileName + '"',
    '', SW_HIDE, ewWaitUntilTerminated, ResultCode
  );

  if LoadStringFromFile(TmpFileName, ExecStdOut) then begin
      if not (Pos('Git\cmd', ExtractFilePath(ExecStdOut)) = 0) then begin
        // Proxy Git path detected
        Result := ExpandConstant('{pf}');
      if Is64BitInstallMode then
        Result := Result + '\Git\mingw64\bin'
      else
        Result := Result + '\Git\mingw32\bin';
      end else begin
        Result := ExtractFilePath(ExecStdOut);
      end;

      DeleteFile(TmpFileName);
  end;
end;

// Checks to see if we need to add the dir to the env PATH variable.
function NeedsAddPath(Param: string): boolean;
var
  OrigPath: string;
  ParamExpanded: string;
begin
  //expand the setup constants like {app} from Param
  ParamExpanded := ExpandConstant(Param);
  if not RegQueryStringValue(HKEY_LOCAL_MACHINE,
    'SYSTEM\CurrentControlSet\Control\Session Manager\Environment',
    'Path', OrigPath)
  then begin
    Result := True;
    exit;
  end;
  // look for the path with leading and trailing semicolon and with or without \ ending
  // Pos() returns 0 if not found
  Result := Pos(';' + UpperCase(ParamExpanded) + ';', ';' + UpperCase(OrigPath) + ';') = 0;
  if Result = True then
    Result := Pos(';' + UpperCase(ParamExpanded) + '\;', ';' + UpperCase(OrigPath) + ';') = 0;
end;

// Runs the lfs initialization.
procedure InstallGitLFS();
var
  ResultCode: integer;
begin
  Exec(
    ExpandConstant('{cmd}'),
    ExpandConstant('/C ""{app}\git-lfs.exe" install"'),
    '', SW_HIDE, ewWaitUntilTerminated, ResultCode
  );
  if not ResultCode = 1 then
    MsgBox(
    'Git LFS was not able to automatically initialize itself. ' +
    'Please run "git lfs install" from the commandline.', mbInformation, MB_OK);
end;

// Event function automatically called when uninstalling:
function InitializeUninstall(): Boolean;
var
  ResultCode: integer;
begin
  Exec(
    ExpandConstant('{cmd}'),
    ExpandConstant('/C ""{app}\git-lfs.exe" uninstall"'),
    '', SW_HIDE, ewWaitUntilTerminated, ResultCode
  );
  Result := True;
end;

#define MyAppName "Git LFS"

; Misuse RemoveFileExt to strip the 4th patch-level version number.
; Arbitrarily choose the x86 executable here as both have the version embedded.
#define MyAppVersion RemoveFileExt(GetFileVersion("..\..\git-lfs-x86.exe"))

#define MyAppPublisher "GitHub, Inc."
#define MyAppURL "https://git-lfs.github.com/"
#define MyAppFilePrefix "git-lfs-windows"

[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={{286391DE-F778-44EA-9375-1B21AAA04FF0}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
LicenseFile=..\..\LICENSE.md
OutputBaseFilename={#MyAppFilePrefix}-{#MyAppVersion}
OutputDir=..\..\
Compression=lzma
SolidCompression=yes
DefaultDirName={pf}\{#MyAppName}
UsePreviousAppDir=no
DirExistsWarning=no
DisableReadyPage=True
ArchitecturesInstallIn64BitMode=x64
ChangesEnvironment=yes
SetupIconFile=git-lfs-logo.ico
WizardImageFile=git-lfs-wizard-image.bmp
WizardSmallImageFile=git-lfs-logo.bmp

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

[Run]
; Uninstalls the old Git LFS version that used a different installer in a different location:
;  If we don't do this, Git will prefer the old version as it is in the same directory as it.
Filename: "{code:GetExistingGitInstallation}\git-lfs-uninstaller.exe"; Parameters: "/S"; Flags: skipifdoesntexist

[Files]
Source: ..\..\git-lfs-x64.exe; DestDir: "{app}"; Flags: ignoreversion; DestName: "git-lfs.exe"; AfterInstall: InstallGitLFS; Check: Is64BitInstallMode
Source: ..\..\git-lfs-x86.exe; DestDir: "{app}"; Flags: ignoreversion; DestName: "git-lfs.exe"; AfterInstall: InstallGitLFS; Check: not Is64BitInstallMode

[Registry]
Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};{app}"; Check: NeedsAddPath('{app}')
Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType: string; ValueName: "GIT_LFS_PATH"; ValueData: "{app}"

[Code]
// Uses cmd to parse and find the location of Git through the env vars.
// Currently only used to support running the uninstaller for the old Git LFS version.
function GetExistingGitInstallation(Value: string): string;
var
  TmpFileName: String;
  ExecStdOut: AnsiString;
  ResultCode: integer;

begin
  TmpFileName := ExpandConstant('{tmp}') + '\git_location.txt';

  Exec(
    ExpandConstant('{cmd}'),
    '/C "for %i in (git.exe) do @echo. %~$PATH:i > "' + TmpFileName + '"',
    '', SW_HIDE, ewWaitUntilTerminated, ResultCode
  );

  if LoadStringFromFile(TmpFileName, ExecStdOut) then begin
      if not (Pos('Git\cmd', ExtractFilePath(ExecStdOut)) = 0) then begin
        // Proxy Git path detected
        Result := ExpandConstant('{pf}');
      if Is64BitInstallMode then
        Result := Result + '\Git\mingw64\bin'
      else
        Result := Result + '\Git\mingw32\bin';
      end else begin
        Result := ExtractFilePath(ExecStdOut);
      end;

      DeleteFile(TmpFileName);
  end;
end;

// Checks to see if we need to add the dir to the env PATH variable.
function NeedsAddPath(Param: string): boolean;
var
  OrigPath: string;
  ParamExpanded: string;
begin
  //expand the setup constants like {app} from Param
  ParamExpanded := ExpandConstant(Param);
  if not RegQueryStringValue(HKEY_LOCAL_MACHINE,
    'SYSTEM\CurrentControlSet\Control\Session Manager\Environment',
    'Path', OrigPath)
  then begin
    Result := True;
    exit;
  end;
  // look for the path with leading and trailing semicolon and with or without \ ending
  // Pos() returns 0 if not found
  Result := Pos(';' + UpperCase(ParamExpanded) + ';', ';' + UpperCase(OrigPath) + ';') = 0;
  if Result = True then
    Result := Pos(';' + UpperCase(ParamExpanded) + '\;', ';' + UpperCase(OrigPath) + ';') = 0;
end;

// Runs the lfs initialization.
procedure InstallGitLFS();
var
  ResultCode: integer;
begin
  Exec(
    ExpandConstant('{cmd}'),
    ExpandConstant('/C ""{app}\git-lfs.exe" install"'),
    '', SW_HIDE, ewWaitUntilTerminated, ResultCode
  );
  if not ResultCode = 1 then
    MsgBox(
    'Git LFS was not able to automatically initialize itself. ' +
    'Please run "git lfs install" from the commandline.', mbInformation, MB_OK);
end;

// Event function automatically called when uninstalling:
function InitializeUninstall(): Boolean;
var
  ResultCode: integer;
begin
  Exec(
    ExpandConstant('{cmd}'),
    ExpandConstant('/C ""{app}\git-lfs.exe" uninstall"'),
    '', SW_HIDE, ewWaitUntilTerminated, ResultCode
  );
  Result := True;
end;