Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1314
  • Last Modified:

Help Modding Inno Setup Script

Hi can someone please help me mod this script as sometimes the pc has not ascociated the file so i need to tell it on import if the box is ticked to import into a program..

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

#define MyAppName "My Program"
#define MyAppVersion "1.5"
#define MyAppPublisher "My Company, Inc."
#define MyAppURL "http://www.example.com/"
#define MyAppExeName "MyProg.exe"

[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{BC8A44BE-0724-49A7-8947-E58B8C29AFA7}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
OutputBaseFilename=setup
Compression=lzma
SolidCompression=yes
DisableFinishedPage=Yes

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

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

[Files]
Source: "C:\util\innosetup\Examples\MyProg.exe"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

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

[Code]
var
  Page: TInputOptionWizardPage;
  IsRegisteredUser: Boolean;

procedure LoadELD;
var
ErrorCode: Integer;

begin
ShellExec('open', ExpandConstant('{app}\test.ELD'),'', '', SW_SHOW, ewNoWait, ErrorCode)
end;

procedure InitializeWizard();
begin
Page := CreateInputOptionPage(wpInfoAfter,
  'Finish', 'Launch ELD?',
  'If you want to launch ELD, please check the box below, then click Next.',
  False, False);

// Add items
Page.Add('Launch ELD');

// Set initial values (optional)
Page.Values[0] := True;
end;

procedure CurPageChanged(CurPageID: Integer);
begin
  if CurPageID = Page.Id then
    WizardForm.NextButton.Caption := 'Finish';
end;

function NextButtonClick(CurPageID: Integer): Boolean;
begin
if CurPageID = Page.Id then 
  begin
  if Page.Values[0] then
    LoadELD;
  end;
Result:= true;
end;

Open in new window


i think its near bottom

begin
ShellExec('open', ExpandConstant('{app}\test.ELD'),'', '', SW_SHOW, ewNoWait, ErrorCode)
end;

Where i need to mod to tell it to look for the program here which this file needs.
{pf}\TS Support\TS.exe

Thanks

0
DiGiTaLReePer
Asked:
DiGiTaLReePer
  • 4
  • 3
1 Solution
 
mirtheilCommented:
If the file association isn't set up, the shellexec won't work.  
You can use Exec in your code like:
 
procedure LoadELD;
var
ErrorCode: Integer;

begin
if Exec(ExpandConstant('{pf}\TS Support\TS.exe'), ExpandConstant('{app}\test.ELD'), '', SW_SHOW,
     ewWaitUntilTerminated, ErrorCode) then
  begin
    // handle success if necessary; ResultCode contains the exit code
  end
  else begin
    // handle failure if necessary; ResultCode contains the error code
  end;
end;

Open in new window


However, a cleaner way is to use the [Run] entry like:
 
[Run]
Filename: "{pf}\TS Support\TS.exe"; Parameters: "{app}\test.ELD"; Description: "{cm:LaunchProgram,HTS}";   Flags:  postinstall shellexec

Open in new window

Using the [Run] entry, you don't need all the custom code to hide the Finish page or create your own page with the checkbox.
0
 
DiGiTaLReePerAuthor Commented:
Hi

Yes I have tried this but I get errors due to shell32

0
 
mirtheilCommented:
What is the exact error?
Did you try both options I posted?  
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
DiGiTaLReePerAuthor Commented:
Hi sorry i was not being clear, my fault..

i havre tried both methods which you gave but the problem is it tried to open the file rather than import it..

in the file there is open and impor this triggers it to try and open the file, should i find out the exact command to inititate?
thanks

Chris
0
 
mirtheilCommented:
If there's two function (Open and Import), you'd want to find the command line option to trigger the import then use that in the Exec or Run command.  If you need help with the parameters, post the command line for the import, then we can offer help.
0
 
DiGiTaLReePerAuthor Commented:
Hi found it finally :)

Ok the program is SEFUtility.exe and you pass an xml file to it which makes it work so the actual commpand is

{pf}\UTILITY\SEFUtility.exe "{app}\extract.xml"

How can i bod this code to make that happen please?

 
[Code]
var
  Page: TInputOptionWizardPage;
  IsRegisteredUser: Boolean;

procedure LoadELD;
var
ErrorCode: Integer;

begin
ShellExec('open', ExpandConstant('{app}\test.sef'),'', '', SW_SHOW, ewNoWait, ErrorCode)
end;

procedure InitializeWizard();
begin
Page := CreateInputOptionPage(wpInfoAfter,
  'SEF Importer', 'Would you like us to import your Indicator into MultiCharts?',
  'If you want to import the HTS into MiltiCharts now, please check the box below, then click Next.',
  False, False);

// Add items
Page.Add('Import SEF');

// Set initial values (optional)
Page.Values[0] := True;
end;

procedure CurPageChanged(CurPageID: Integer);
begin
  if CurPageID = Page.Id then
    WizardForm.NextButton.Caption := 'Next';
end;

function NextButtonClick(CurPageID: Integer): Boolean;
begin
if CurPageID = Page.Id then 
  begin
  if Page.Values[0] then
    LoadELD;
  end;
Result:= true;
end;

Open in new window

0
 
mirtheilCommented:
You'd do something like this:
procedure LoadELD;
var
ErrorCode: Integer;

begin
if Exec(ExpandConstant('{pf}\UTILITY\SEFUtility.exe'), ExpandConstant('{app}\extract.xml'), '', SW_SHOW,
     ewWaitUntilTerminated, ErrorCode) then
  begin
    // handle success if necessary; ResultCode contains the exit code
  end
  else begin
    // handle failure if necessary; ResultCode contains the error code
  end;
end;

Open in new window

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now