ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Other Software > Developer's Corner

Need help from Inno Setup gurus

(1/5) > >>

kyrathaba:
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...

Renegade:
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.

skwire:
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:
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:
Thanks, works great!

Navigation

[0] Message Index

[#] Next page

Go to full version