Solved

Inno Setup:  NeedRestart function help....

Posted on 2007-04-04
3
5,342 Views
Last Modified: 2013-12-03
My Inno Setup uses isxdl.iss to download the main executable.  It works flowless, but recently, I added a NeedRestart() function for Vista Users.  The problem is that when the user clicks the "finish" button, the setup begins downloading again.  What am I doing wrong? Perhaps I am not exiting the if statement correctly?  If you do not have vista, simply change the line Result := true; when you see it the comments "//change to true only to test in other than vista"

Here's the entire code:

#include "isxdl.iss"

[Setup]
AppName=WebConference.com
AppVerName=WebConference.com V5.1.239
AppPublisher=webconference.com
AppPublisherURL=http://www.webconference.com
AppSupportURL=http://www.webconference.com/webconferencing/twopanel.php?quick=support
AppUpdatesURL=http://www.webconference.com
DefaultDirName={code:MyConst}\WebConference.com\Version51239
DisableDirPage=true
DefaultGroupName=WebConference.com
DisableProgramGroupPage=true
SetupIconFile=setupicon2.ico
DisableReadyPage=true
DisableFinishedPage=true
Compression=lzma/max
SolidCompression=yes
ShowLanguageDialog=no
AlwaysShowComponentsList=false
ShowComponentSizes=false
FlatComponentsList=false
UsePreviousSetupType=false
UsePreviousTasks=false
AppCopyright=© WebConference.com
UninstallDisplayIcon={app}\webconference.exe
WizardImageFile=D:\SourceCode\WebConference.com\Webconference.com V5.1.0.239-Current\inno\WizModernImage-IS.bmp
WizardImageStretch=false
WizardSmallImageFile=D:\SourceCode\WebConference.com\Webconference.com V5.1.0.239-Current\inno\WizModernSmallImage-IS.bmp
WindowVisible=true
WindowShowCaption=false
AlwaysUsePersonalGroup=yes
VersionInfoVersion =  6.0.0.0

[Files]
Source: C:\Program Files\Download DLL\languages\english.ini; Flags: dontcopy
Source: {tmp}\webconference.exe; DestDir: {app}; Flags: external skipifsourcedoesntexist
Source: {tmp}\webcbrowser.exe; DestDir: {app}; Flags: external skipifsourcedoesntexist

[Code]
const
      // Inno Setup
      url1 = 'http://www.webconference.com/downloads/v5install/webconference.exe';
      url2 = 'http://www.webconference.com/downloads/v5install/webcbrowser.exe';


function NextButtonClick(CurPage: Integer): Boolean;
var
  hWnd: Integer;
  sFileName: String;
  sTasks: String;
  nCode: Integer;
  sAdmin: Boolean;
  sPower: Boolean;
  cMutex: Boolean;
begin
  Result := true;

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

    sTasks := WizardSelectedTasks(true);

    isxdl_ClearFiles;

    sAdmin := IsAdminLoggedOn;
    sPower := IsPowerUserLoggedOn;
   
    if sAdmin or sPower = true then begin
      //write webconference.exe in data execution prevention list
      RegWriteStringValue(HKEY_LOCAL_MACHINE, 'Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers',ExpandConstant('{pf}\WebConference.com\Version51239\webconference.exe'), 'DisableNXShowUI');

      sFileName := ExpandConstant('{tmp}\webconference.exe');
      isxdl_AddFile(url1,sFileName);
      if isxdl_DownloadFiles(hWnd) <> 0 then begin
        sFileName := ExpandConstant('{tmp}\webconference.exe');
        //if FileExists(sFileName) then Exec(sFileName,'','',SW_SHOW,ewWaitUntilTerminated,nCode)
      end else
        Result := false;
    end
    if sAdmin or sPower = false then begin

      // Ask the user a Yes/No question
      if MsgBox('You are not logged in with an Administrator Account.' + chr(13) + 'After installation, close the browser and join the conference '+ chr(13) +'by double-clicking on the WC icon on the Desktop' + chr(13) + 'YOU MUST JOIN ALL FUTURE CONFERENCES THROUGH THIS ICON', mbConfirmation, MB_YESNO) = IDYES then begin
        // user clicked Yes
       
       //write webconference.exe in data execution prevention list
      RegWriteStringValue(HKEY_LOCAL_MACHINE, 'Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers',ExpandConstant('{sd}\WebConference.com\Version51239\webcbrowser.exe'), 'DisableNXShowUI');

       
        sFileName := ExpandConstant('{tmp}\webcbrowser.exe');
        isxdl_AddFile(url2,sFileName);
          if isxdl_DownloadFiles(hWnd) <> 0 then begin
              sFileName := ExpandConstant('{tmp}\webcbrowser.exe');
              //if FileExists(sFileName) then Exec(sFileName,'','',SW_SHOW,ewWaitUntilTerminated,nCode)
          end else
              Result := false;
       end else
         Result := false;
     end
end;

function InitializeSetup: Boolean;
begin
  ExtractTemporaryFile('english.ini');
  isxdl_SetOption('language',ExpandConstant('{tmp}\english.ini'));
  isxdl_SetOption('title','WebConference.com is Downloading. Please wait...');
  isxdl_SetOption('label','Download');
  isxdl_SetOption('description','In Progress...');
  //isxdl_SetOption('resume','false');
  isxdl_SetOption('smallwizardimage','D:\SourceCode\WebConference.com\Webconference.com V5.1.0.239-Current\inno\WizModernSmallImage-IS.bmp');

  Result := true;
end;

function MyConst(Param: String): String;
var
  sAdmin: Boolean;
  sPower: Boolean;
begin
    sAdmin := IsAdminLoggedOn;
    sPower := IsPowerUserLoggedOn;
  if sAdmin or sPower = true then begin
    Result := ExpandConstant('{pf}');
  end else
    Result := ExpandConstant('{sd}');
end;

function NeedRestart(): Boolean;
var
  Version: TWindowsVersion;
begin
   GetWindowsVersionEx(Version);
    // On Windows VISTA
  if Version.NTPlatform and (Version.Major = 6) then begin
     Result := true;
     exit;
  end else
     Result := false;//change to true only to test in other than vista
     exit;
end;

[Icons]
; NOTE: The following entry contains an English phrase ("Uninstall"). You are free to translate it into another language if required.
Name: {group}\WebConference.com; Filename: {app}\webconference.exe; Parameters: website; Flags: createonlyiffileexists
Name: {group}\Upload PowerPoints To Your Account; Filename: {app}\webconference.exe; Parameters: upload; Flags: createonlyiffileexists
Name: {group}\Advanced Connection Settings; Filename: {app}\webconference.exe; Parameters: connectionsettings; Flags: createonlyiffileexists
Name: {userdesktop}\WebConference.com; Filename: {app}\webconference.exe; Parameters: website; Flags: createonlyiffileexists
Name: {group}\WebConference.com; Filename: {app}\webcbrowser.exe; Flags: createonlyiffileexists
Name: {userdesktop}\WebConference.com; Filename: {app}\webcbrowser.exe; Flags: createonlyiffileexists
Name: {group}\Firewall Test; Filename: {app}\firewalltest.url
Name: {group}\Security & Hipaa WhitePaper; Filename: {app}\security.url
Name: {group}\Paypal Integration WhitePaper; Filename: {app}\paypal.url
Name: {group}\Live Help Integration WhitePaper; Filename: {app}\livehelp.url
Name: {group}\Demo; Filename: {app}\demo.url
Name: {group}\Tell a friend; Filename: {app}\tellafriend.url
Name: {group}\Uninstall WebConference.com; Filename: {uninstallexe}

[Run]
; NOTE: The following entry contains an English phrase ("Launch"). You are free to translate it into another language if required.
Filename: {app}\webconference.exe; Description: Launch WebConference.com; Flags: nowait skipifdoesntexist
Filename: {app}\webcbrowser.exe; Description: Launch WebConference.com; Flags: nowait skipifdoesntexist

[UninstallDelete]
Type: files; Name: {app}\webconference.exe
Type: files; Name: {app}\webcbrowser.exe
Type: files; Name: {app}\webchooks.dll
Type: files; Name: {app}\ScreenCap.ax
Type: files; Name: {app}\security.url
Type: files; Name: {app}\paypal.url
Type: files; Name: {app}\demo.url
Type: files; Name: {app}\tellafriend.url
Type: files; Name: {app}\firewalltest.url
Type: files; Name: {app}\livehelp.url

[INI]
Filename: {app}\security.url; Section: InternetShortcut; Key: URL; String: http://www.webconference.com/webconferencing/content/documentation/WebConfandHipaa.pdf
Filename: {app}\paypal.url; Section: InternetShortcut; Key: URL; String: http://www.webconference.com/webconferencing/content/documentation/paypalintegration.pdf
Filename: {app}\demo.url; Section: InternetShortcut; Key: URL; String: http://www.webconference.com/webconferencing/popups/quickdemo.html
Filename: {app}\firewalltest.url; Section: InternetShortcut; Key: URL; String: https://www.webconference.com/setup/v5/
Filename: {app}\livehelp.url; Section: InternetShortcut; Key: URL; String: http://www.webconference.com/webconferencing/content/documentation/WebConf_LiveHelp.pdf

0
Comment
Question by:frankmorrison
  • 2
3 Comments
 
LVL 18

Expert Comment

by:mirtheil
ID: 18856899
I believe the problem is in the NextButtonClick function. Your code as written will run the functions in the NextButtonClick on every Next Button click.  You probably want to limit it to one specific page by using the
CurPage value.
0
 
LVL 1

Author Comment

by:frankmorrison
ID: 18859549
Mirtheil,
Being that I am very unfamiliar with this, can you please give me some sample code?
0
 
LVL 18

Accepted Solution

by:
mirtheil earned 500 total points
ID: 18859875
Well, you'll want to decide when the code in the NextButtonClick event is supposed to run.  For example, do you want it to run after you've picked the installation directory?  For example, if you wanted it to happen after the Finish button is clicked, then you would use something like:
[code]
function NextButtonClick(CurPage: Integer): Boolean;
var
  hWnd: Integer;
  sFileName: String;
  sTasks: String;
  nCode: Integer;
  sAdmin: Boolean;
  sPower: Boolean;
  cMutex: Boolean;
begin
  Result := true;
  if CurPage = wpFinished then
  begin
    hWnd := StrToInt(ExpandConstant('{wizardhwnd}'));

    sTasks := WizardSelectedTasks(true);

    isxdl_ClearFiles;

    sAdmin := IsAdminLoggedOn;
    sPower := IsPowerUserLoggedOn;

    if sAdmin or sPower = true then begin
      //write webconference.exe in data execution prevention list
      RegWriteStringValue(HKEY_LOCAL_MACHINE, 'Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers',ExpandConstant('{pf}\WebConference.com\Version51239\webconference.exe'), 'DisableNXShowUI');

      sFileName := ExpandConstant('{tmp}\webconference.exe');
      isxdl_AddFile(url1,sFileName);
      if isxdl_DownloadFiles(hWnd) <> 0 then begin
        sFileName := ExpandConstant('{tmp}\webconference.exe');
        //if FileExists(sFileName) then Exec(sFileName,'','',SW_SHOW,ewWaitUntilTerminated,nCode)
      end else
        Result := false;
    end
    if sAdmin or sPower = false then begin

      // Ask the user a Yes/No question
      if MsgBox('You are not logged in with an Administrator Account.' + chr(13) + 'After installation, close the browser and join the conference '+ chr(13) +'by double-clicking on the WC icon on the Desktop' + chr(13) + 'YOU MUST JOIN ALL FUTURE CONFERENCES THROUGH THIS ICON', mbConfirmation, MB_YESNO) = IDYES then begin
        // user clicked Yes

       //write webconference.exe in data execution prevention list
      RegWriteStringValue(HKEY_LOCAL_MACHINE, 'Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers',ExpandConstant('{sd}\WebConference.com\Version51239\webcbrowser.exe'), 'DisableNXShowUI');


        sFileName := ExpandConstant('{tmp}\webcbrowser.exe');
        isxdl_AddFile(url2,sFileName);
          if isxdl_DownloadFiles(hWnd) <> 0 then begin
              sFileName := ExpandConstant('{tmp}\webcbrowser.exe');
              //if FileExists(sFileName) then Exec(sFileName,'','',SW_SHOW,ewWaitUntilTerminated,nCode)
          end else
              Result := false;
       end else
         Result := false;
     end;
  end;
end;
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the frequent problems with the installations is when some file or registry entry is not removed from the system upon un-installation of the product. Clean removal is always highly desirable. One major reason for that is badly authored inst…
I have been scripting applications way too long and can never remember how to create an ISS file.  So I decided to write this article to act as my own knowledge base for future reference, and hope you will also benefit. An ISS file is a response …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question