[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

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

Inno Setup: NeedRestart function help....

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
frankmorrison
Asked:
frankmorrison
  • 2
1 Solution
 
mirtheilCommented:
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
 
frankmorrisonAuthor Commented:
Mirtheil,
Being that I am very unfamiliar with this, can you please give me some sample code?
0
 
mirtheilCommented:
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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

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