Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Inno Setup:  NeedRestart function help....

Posted on 2007-04-04
3
Medium Priority
?
5,467 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

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…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
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…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

618 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