install.iss 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. ;
  2. ; install.iss -- Inno Setup 4 install configuration file for Embedthis GoAhead
  3. ;
  4. ; Copyright (c) Embedthis Software LLC, 2003-2014. All Rights Reserved.
  5. ;
  6. [Setup]
  7. AppName=${settings.title}
  8. AppVerName=${settings.title} ${settings.version}
  9. DefaultDirName={pf}\${settings.title}
  10. DefaultGroupName=${settings.title}
  11. UninstallDisplayIcon={app}/${settings.name}.exe
  12. LicenseFile=LICENSE.TXT
  13. ChangesEnvironment=yes
  14. ArchitecturesInstallIn64BitMode=x64
  15. [Icons]
  16. Name: "{group}\${settings.title} shell"; Filename: "{app}/bin/${settings.name}.exe"; Parameters: ""
  17. Name: "{group}\${settings.title} documentation"; Filename: "{app}/doc/index.html"; Parameters: ""
  18. Name: "{group}\ReadMe"; Filename: "{app}/README.TXT"
  19. [Dirs]
  20. Name: "{app}/bin"
  21. [UninstallDelete]
  22. [Tasks]
  23. Name: addpath; Description: Add ${settings.title} to the system PATH variable;
  24. [Code]
  25. function IsPresent(const file: String): Boolean;
  26. begin
  27. file := ExpandConstant(file);
  28. if FileExists(file) then begin
  29. Result := True;
  30. end else begin
  31. Result := False;
  32. end
  33. end;
  34. //
  35. // Initial sample by Jared Breland
  36. //
  37. procedure AddPath(keyName: String; dir: String);
  38. var
  39. newPath, oldPath, key: String;
  40. paths: TArrayOfString;
  41. i: Integer;
  42. regHive: Integer;
  43. begin
  44. if (IsAdminLoggedOn or IsPowerUserLoggedOn) then begin
  45. regHive := HKEY_LOCAL_MACHINE;
  46. key := 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment';
  47. end else begin
  48. regHive := HKEY_CURRENT_USER;
  49. key := 'Environment';
  50. end;
  51. i := 0;
  52. if RegValueExists(regHive, key, keyName) then begin
  53. RegQueryStringValue(regHive, key, keyName, oldPath);
  54. oldPath := oldPath + ';';
  55. while (Pos(';', oldPath) > 0) do begin
  56. SetArrayLength(paths, i + 1);
  57. paths[i] := Copy(oldPath, 0, Pos(';', oldPath) - 1);
  58. oldPath := Copy(oldPath, Pos(';', oldPath) + 1, Length(oldPath));
  59. i := i + 1;
  60. if dir = paths[i - 1] then begin
  61. continue;
  62. end;
  63. if i = 1 then begin
  64. newPath := paths[i - 1];
  65. end else begin
  66. newPath := newPath + ';' + paths[i - 1];
  67. end;
  68. end;
  69. end;
  70. if (IsUninstaller() = false) and (dir <> '') then begin
  71. if (newPath <> '') then begin
  72. newPath := newPath + ';' + dir;
  73. end else begin
  74. newPath := dir;
  75. end;
  76. end;
  77. RegWriteStringValue(regHive, key, keyName, newPath);
  78. end;
  79. procedure CurStepChanged(CurStep: TSetupStep);
  80. var
  81. bin: String;
  82. begin
  83. if CurStep = ssPostInstall then
  84. if IsTaskSelected('addpath') then begin
  85. bin := ExpandConstant('{app}\bin');
  86. AddPath('Path', bin);
  87. end;
  88. end;
  89. procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
  90. var
  91. app: String;
  92. bin: String;
  93. begin
  94. if CurUninstallStep = usUninstall then begin
  95. bin := ExpandConstant('{app}\bin');
  96. AddPath('Path', bin);
  97. end;
  98. if CurUninstallStep = usDone then begin
  99. app := ExpandConstant('{app}');
  100. RemoveDir(app);
  101. end;
  102. end;
  103. [Run]
  104. Filename: "file:///{app}/doc/index.html"; Description: "View the Documentation"; Flags: skipifsilent waituntilidle shellexec postinstall; Check: IsPresent('{app}/doc/index.html');
  105. [UninstallRun]
  106. Filename: "{app}/bin/removeFiles.exe"; Parameters: "-r -s 5"; WorkingDir: "{app}"; Flags:
  107. [Files]