Solved

Inno Setup:  NeedRestart function help....

Posted on 2007-04-04
3
5,269 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
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…

762 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now