topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Tuesday March 19, 2024, 12:53 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Need help from Inno Setup gurus  (Read 18184 times)

kyrathaba

  • N.A.N.Y. Organizer
  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 3,200
    • View Profile
    • Donate to Member
Need help from Inno Setup gurus
« on: December 19, 2010, 08:27 PM »
I know it doesn't make sense, but although I have the patience and drive to write computer applications, I don't seem to have the patience to figure out InnoSetup.  I have managed to figure out a script for a basic install, and the script checks for the installation of the .NET Framework 4.0 and, if it isn't found, prompts for its download.  

I'm showing my existing .iss script.  I'm wondering if anyone can show me exactly how to modify it,  such that it will additionally prompt for a desktop shortcut to be created during setup.

The script shown below compiles successfully, and I've tested the setup it creates, and it works as desired, except I want to modify it to give the user the option to create a desktop icon during the setup process.

I know it isn't kosher, and I normally would not use this feature, but I'd also like to know how to install the desktop shortcut without prompting the user.  The reason is, sometimes I write short little helper programs for my elderly father, who is so computer challenged, he can't find the program in the program menu.  He really needs (and wants) a desktop shortcut when he installs one of my apps.

[_ISTool]
EnableISX=true

[Setup]
AppName=TestProgram
AppVerName=TestProgram1.0
MinVersion=4.1,4.0
DefaultDirName={pf}\Kyrathasoft
DefaultGroupName=TestProgram
UninstallDisplayIcon={app}\UninstallCharCreator.exe
Compression=lzma
SolidCompression=true
OutputBaseFilename=TestProgramSetup

[Files]
Source: scripts\isxdl\isxdl.dll; Flags: dontcopy
Source: src\TestProgForInnoSetup.exe; DestDir: {app}

[Messages]
WinVersionTooLowError=This application requires Windows NT4, Windows 98 or later.

[Icons]
Name: {group}\Kyrathasoft\TestProgram; Filename: {app}\TestProgForInnoSetup.exe
Name: {group}\Uninstall TestProgram; Filename: {uninstallexe}

[code]
var
  dotnetRedistPath: string;
  downloadNeeded: boolean;
  dotNetNeeded: boolean;
  memoDependenciesNeeded: string;

procedure isxdl_AddFile(URL, Filename: PChar);
external 'isxdl_AddFile@files:isxdl.dll stdcall';
function isxdl_DownloadFiles(hWnd: Integer): Integer;
external 'isxdl_DownloadFiles@files:isxdl.dll stdcall';
function isxdl_SetOption(Option, Value: PChar): Integer;
external 'isxdl_SetOption@files:isxdl.dll stdcall';


const
  dotnetRedistURL = 'http://download.microsoft.com/download/9/5/A/95A9616B-7A37-4AF6-BC36-D6EA96C8DAAE/dotNetFx40_Full_x86_x64.exe';
  //dotnetRedistURL = 'http://download.microsoft.com/download/a/a/c/aac39226-8825-44ce-90e3-bf8203e74006/dotnetfx.exe'; //for v1 of framework
  // local system for testing...
  // dotnetRedistURL = 'http://192.168.1.1/dotnetfx.exe';

function InitializeSetup(): Boolean;

begin
  Result := true;
  dotNetNeeded := false;

  // Check for required netfx installation
  if (not RegKeyExists(HKLM, 'Software\Microsoft\NET Framework Setup\NDP\v4\Client')) then begin
    dotNetNeeded := true;
    if (not IsAdminLoggedOn()) then begin
      MsgBox('This application needs the Microsoft .NET Framework to be installed by an Administrator', mbInformation, MB_OK);
      Result := false;
    end else begin
      memoDependenciesNeeded := memoDependenciesNeeded + '      .NET Framework' #13;
      dotnetRedistPath := ExpandConstant('{src}\dotnetfx.exe');
      if not FileExists(dotnetRedistPath) then begin
        dotnetRedistPath := ExpandConstant('{tmp}\dotnetfx.exe');
        if not FileExists(dotnetRedistPath) then begin
          isxdl_AddFile(dotnetRedistURL, dotnetRedistPath);
          downloadNeeded := true;
        end;
      end;
      SetIniString('install', 'dotnetRedist', dotnetRedistPath, ExpandConstant('{tmp}\dep.ini'));
    end;
  end;

end;

function NextButtonClick(CurPage: Integer): Boolean;
var
  hWnd: Integer;
  ResultCode: Integer;

begin
  Result := true;

  if CurPage = wpReady then begin

    hWnd := StrToInt(ExpandConstant('{wizardhwnd}'));

    // don't try to init isxdl if it's not needed because it will error on < ie 3
    if downloadNeeded then begin

      isxdl_SetOption('label', 'Downloading Microsoft .NET Framework');
      isxdl_SetOption('description', 'MyApp needs to install the Microsoft .NET Framework. Please wait while Setup is downloading extra files to your computer.');
      if isxdl_DownloadFiles(hWnd) = 0 then Result := false;
    end;
    if (Result = true) and (dotNetNeeded = true) then begin
      if Exec(ExpandConstant(dotnetRedistPath), '', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then begin
         // handle success if necessary; ResultCode contains the exit code
         if not (ResultCode = 0) then begin
           Result := false;
         end;
      end else begin
         // handle failure if necessary; ResultCode contains the error code
         Result := false;
      end;
    end;
  end;
end;

function UpdateReadyMemo(Space, NewLine, MemoUserInfoInfo, MemoDirInfo, MemoTypeInfo, MemoComponentsInfo, MemoGroupInfo, MemoTasksInfo: String): String;
var
  s: string;

begin
  if memoDependenciesNeeded <> '' then s := s + 'Dependencies to install:' + NewLine + memoDependenciesNeeded + NewLine;
  s := s + MemoDirInfo + NewLine + NewLine;

  Result := s
end;
[/code]

BTW, I have double- and triple-checked that I have only the opening and closing code tags, but everytime I "Save" this post, an extra closing tag gets inserted...
« Last Edit: December 19, 2010, 08:37 PM by kyrathaba »

Renegade

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 13,288
  • Tell me something you don't know...
    • View Profile
    • Renegade Minds
    • Donate to Member
Re: Need help from Inno Setup gurus
« Reply #1 on: December 19, 2010, 08:32 PM »
You might want to try one of the InnoSetup GUIs here: http://www.jrsoftware.org/is3rdparty.php

It should help out there.

I haven't used it in a long time and don't remember much of anything about it.
Slow Down Music - Where I commit thought crimes...

Freedom is the right to be wrong, not the right to do wrong. - John Diefenbaker

skwire

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,286
    • View Profile
    • Donate to Member
Re: Need help from Inno Setup gurus
« Reply #2 on: December 19, 2010, 08:33 PM »
Create a [Tasks] section like this:

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

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Need help from Inno Setup gurus
« Reply #3 on: December 19, 2010, 08:40 PM »
my inno setup looks similar to Skwire's and i think it does the same thing, but it's split into two sections:

[Icons]
Name: {userdesktop}\Screenshot Captor; Filename: {app}\ScreenshotCaptor.exe; Tasks: desktopicon
[Tasks]
Name: desktopicon; Description: {cm:CreateDesktopIcon}; GroupDescription: {cm:AdditionalIcons}

So note how the desktop icon is setup in the [Icons] section, and has a TASK specified.
And then the task entry asks the user if they want to install it.

kyrathaba

  • N.A.N.Y. Organizer
  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 3,200
    • View Profile
    • Donate to Member
Re: Need help from Inno Setup gurus
« Reply #4 on: December 19, 2010, 08:49 PM »
Thanks, works great!

kyrathaba

  • N.A.N.Y. Organizer
  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 3,200
    • View Profile
    • Donate to Member
Re: Need help from Inno Setup gurus
« Reply #5 on: December 19, 2010, 08:57 PM »
Another question.  The screenshot posted below should help explain.  I want to change the Program Files menu so that instead of looking like it does on the left of the screenshot, it instead looks like what I show on the right.  Can you show me what to change in my *.iss script?

installShot.png

kyrathaba

  • N.A.N.Y. Organizer
  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 3,200
    • View Profile
    • Donate to Member
Re: Need help from Inno Setup gurus
« Reply #6 on: December 19, 2010, 09:12 PM »
Solved it:


[_ISTool]
EnableISX=true

[Setup]
AppName=TestProgram
AppVerName=TestProgram1.0
MinVersion=4.1,4.0
DefaultDirName={pf}\Kyrathasoft
DefaultGroupName=Kyrathasoft
UninstallDisplayIcon={app}\UninstallCharCreator.exe
Compression=lzma
SolidCompression=true
OutputBaseFilename=TestProgramSetup

[Files]
Source: scripts\isxdl\isxdl.dll; Flags: dontcopy
Source: src\TestProgForInnoSetup.exe; DestDir: {app}

[Messages]
WinVersionTooLowError=This application requires Windows NT4, Windows 98 or later.

[Icons]
Name: {group}\TestProgram; Filename: {app}\TestProgForInnoSetup.exe
Name: {group}\Uninstall TestProgram; Filename: {uninstallexe}
Name: {userdesktop}\Test Program; Filename: {app}\TestProgForInnoSetup.exe; Tasks: desktopicon

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

« Last Edit: December 19, 2010, 09:14 PM by kyrathaba »

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Need help from Inno Setup gurus
« Reply #7 on: December 19, 2010, 09:17 PM »
Can i point out i also recently posted a tiny dll and inno script sample for people who want to have their programs shutdown automatically if running on install and uninstall:

https://www.donation...ex.php?topic=24786.0

kyrathaba

  • N.A.N.Y. Organizer
  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 3,200
    • View Profile
    • Donate to Member
Re: Need help from Inno Setup gurus
« Reply #8 on: December 20, 2010, 12:13 AM »
Thanks for the link, Mouser.

One more question:

Say I want my setup to copy two files (a small JPG, and a small text file) to the same application as the directory.  How do I do that in the script?

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Need help from Inno Setup gurus
« Reply #9 on: December 20, 2010, 08:29 AM »
i'm confused -- are you just asking the general question of how you specify what files get installed by Inno Setup? Or is there something i'm missing?
ps. try one of the Inno Ides, they make life easier.

kyrathaba

  • N.A.N.Y. Organizer
  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 3,200
    • View Profile
    • Donate to Member
Re: Need help from Inno Setup gurus
« Reply #10 on: December 20, 2010, 09:08 AM »
I figured it out. Thanks, all!

Ath

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 3,610
    • View Profile
    • Donate to Member
Re: Need help from Inno Setup gurus
« Reply #11 on: December 26, 2010, 02:24 PM »
@kyrathaba You should really sign up to the news server on jrsoftware.org, it is so helpful if you have questions after reading the fine manual, which you seem to have missed, reading all these n00b questions here...

kyrathaba

  • N.A.N.Y. Organizer
  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 3,200
    • View Profile
    • Donate to Member
Re: Need help from Inno Setup gurus
« Reply #12 on: December 26, 2010, 02:30 PM »
Thanks, Ath.  RTFM, right?  :P

Ath

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 3,610
    • View Profile
    • Donate to Member
Re: Need help from Inno Setup gurus
« Reply #13 on: December 26, 2010, 02:36 PM »
That's what I write several times a month on the NG's there :D

kyrathaba

  • N.A.N.Y. Organizer
  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 3,200
    • View Profile
    • Donate to Member
Re: Need help from Inno Setup gurus
« Reply #14 on: December 27, 2010, 01:08 PM »
Here's a question.  It must be in the manual somewhere, but darned if I can find it:

I'm able to specify a custom icon for the setup installer that Inno Setup creates, by using the following in my script:

[Setup]
SetupIconFile=src\excuseMan.ico

My question, then, is this: how do I similarly specify that same custom icon so that it will be used if the user specifies for a desktop icon to be created?  Something like the following, maybe, but I don't know the correct syntax:

[Setup]
DesktopIconFile=src\excuseMan.ico

worstje

  • Honorary Member
  • Joined in 2009
  • **
  • Posts: 588
  • The Gent with the White Hat
    • View Profile
    • Donate to Member
Re: Need help from Inno Setup gurus
« Reply #15 on: December 27, 2010, 01:17 PM »
Shouldn't you have said desktop icon listed in the [Icons] section?

You can simply use:

IconFilename: "{app}\myicon.ico"

to change the icon used for such an icon.

Ath

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 3,610
    • View Profile
    • Donate to Member
Re: Need help from Inno Setup gurus
« Reply #16 on: December 27, 2010, 01:38 PM »
kryathaba, you could (re)start with a fresh script generated from the wizard, that gives you all this stuff by default...
Then add the extra files you need to add, and don't be shy to use an editor like InnoIDE or ISTool (that one is going off-line right about now) to aid in the setting of 'fancy' features like icons etc.
And don't forget to add the .ico files in the [Files] section.

As said earlier, the newsgroups are quite helpful, but we expect you to have done at least a little homework...

kyrathaba

  • N.A.N.Y. Organizer
  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 3,200
    • View Profile
    • Donate to Member
Re: Need help from Inno Setup gurus
« Reply #17 on: December 27, 2010, 01:46 PM »
As said earlier, the newsgroups are quite helpful, but we expect you to have done at least a little homework...

I find, with a few exceptions, that people on this site respond more quickly and with less chastisement in their tone, and that it saves me time.  DC is like having a bunch of friends who are experts.  Instead of me digging and slogging through dry subject matter, 99.9% of which doesn't pertain, I can get the answer quickly and with little time/energy expenditure.


Thanks for pointing me to those tools :)
« Last Edit: December 27, 2010, 01:48 PM by kyrathaba »

kyrathaba

  • N.A.N.Y. Organizer
  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 3,200
    • View Profile
    • Donate to Member
Re: Need help from Inno Setup gurus
« Reply #18 on: December 27, 2010, 02:43 PM »
Eureka!

[Icons]
Name: {group}\ExcuseManager; Filename: {app}\ExcuseManager.exe
Name: {group}\Uninstall Excuse Manager v0.94; Filename: {uninstallexe}
Name: {userdesktop}\NANY Excuse Manager v0.94; Filename: {app}\ExcuseManager.exe; IconFilename: {app}\excuseMan.ico; Tasks: desktopicon

Ath

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 3,610
    • View Profile
    • Donate to Member
Re: Need help from Inno Setup gurus
« Reply #19 on: December 27, 2010, 02:57 PM »
See, it isn't that hard :D

I'm not sure if putting the version number in the shortcut would be that handy, you would have to clean that up with every upgrade you publish (deleting the .lnk file of that name using [InstallDelete]), but also cater for in your script in any future release, might someone skip/miss one of your in-between updates.

kyrathaba

  • N.A.N.Y. Organizer
  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 3,200
    • View Profile
    • Donate to Member
Re: Need help from Inno Setup gurus
« Reply #20 on: December 27, 2010, 03:18 PM »
Good idea.  I'll remove it for v0.96 release.

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Need help from Inno Setup gurus
« Reply #21 on: December 27, 2010, 03:23 PM »
agree with ATH, using version # in start menus and start menu groups is messy and error prone.