Skip to content

Commit 62df485

Browse files
committed
Added support for an "All users" installation
1 parent cea5579 commit 62df485

File tree

1 file changed

+81
-28
lines changed

1 file changed

+81
-28
lines changed

SeleniumBasicSetup.iss

Lines changed: 81 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ AppPublisherURL={#AppURL}
2424
AppSupportURL={#AppURL}
2525
AppUpdatesURL={#AppURL}
2626
DisableDirPage=yes
27-
DefaultDirName={localappdata}\{#AppFolder}
28-
UsePreviousAppDir=yes
27+
DefaultDirName={code:GetRootDir}
28+
UsePreviousAppDir=no
29+
UsePreviousSetupType=yes
2930
DefaultGroupName={#AppLongName}
3031
DisableProgramGroupPage=yes
3132
LicenseFile=.\LICENSE.txt
@@ -229,12 +230,35 @@ Type: filesandordirs; Name: "{app}"
229230
Type: filesandordirs; Name: "{localappdata}\Temp\Selenium"
230231

231232
[Code]
233+
var
234+
ALL_USERS : Boolean;
235+
HK : Integer;
236+
HK32 : Integer;
232237
233238
Function HasPrivileges(): Boolean;
234239
Begin
235240
Result := IsAdminLoggedOn Or IsPowerUserLoggedOn
236241
End;
237242
243+
Function GetRootDir(Param: String): String;
244+
Begin
245+
If ALL_USERS Then
246+
Result := ExpandConstant('{pf}\{#AppFolder}')
247+
Else
248+
Result := ExpandConstant('{localappdata}\{#AppFolder}');
249+
End;
250+
251+
Procedure InitRootKeys();
252+
Begin
253+
If ALL_USERS Then Begin
254+
HK := HKLM;
255+
HK32 := HKLM32;
256+
End Else Begin
257+
HK := HKCU;
258+
HK32 := HKCU32;
259+
End
260+
End;
261+
238262
Function GetAppPath(app: String): string;
239263
Begin
240264
RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\' + app, '', Result);
@@ -314,15 +338,20 @@ Function UninstallPrevious(const appid: String): Boolean;
314338
Begin
315339
key := 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\' + ExpandConstant(appid) + '_is1';
316340
name := 'UninstallString';
317-
If Not RegQueryStringValue(HKCU, key, name, out_cmd) Then
318-
If Not RegQueryStringValue(HKLM, key, name, out_cmd) Then
319-
If Not RegQueryStringValue(HKCU32, key, name, out_cmd) Then
320-
RegQueryStringValue(HKLM32, key, name, out_cmd);
341+
If Not RegQueryStringValue(HKLM, key, name, out_cmd) Then
342+
If Not RegQueryStringValue(HKLM32, key, name, out_cmd) Then
343+
If Not RegQueryStringValue(HKCU, key, name, out_cmd) Then
344+
RegQueryStringValue(HKCU32, key, name, out_cmd);
321345
If out_cmd <> '' Then
322-
Exec(RemoveQuotes(out_cmd), '/SILENT /NORESTART /SUPPRESSMSGBOXES', '', SW_SHOW, ewWaitUntilTerminated, retcode);
346+
Exec('>', out_cmd + ' /SILENT /NORESTART /SUPPRESSMSGBOXES', '', SW_SHOW, ewWaitUntilTerminated, retcode);
323347
Result := retcode = 0;
324348
End;
325349
350+
Function BoolToStr(const value: Boolean): String;
351+
Begin
352+
If value Then Result := '1' Else Result := '0';
353+
End;
354+
326355
//---------------------------------------------------------------------------------------
327356
// Registration
328357
//---------------------------------------------------------------------------------------
@@ -342,7 +371,7 @@ type
342371
343372
Procedure RegString(Const root: Integer; Const subkey, name, value: String);
344373
Begin
345-
Log('reg [' + subkey + '] "' + name + '"="' + value + '"');
374+
//Log('REG [' + subkey + '] "' + name + '"="' + value + '"');
346375
If Not RegWriteStringValue(root, subkey, name, value) Then
347376
RaiseException(ExpandConstant('{cm:MsgRegistryWriteFailure}'));
348377
End;
@@ -373,9 +402,9 @@ Procedure RegInterface_(Const lib : TNetLib; Const root: Integer; Const guid, ty
373402
374403
Procedure RegInterface(Const lib : TNetLib; Const guid, name, proxystub: String);
375404
Begin
376-
RegInterface_(lib, HKCU, guid, name, proxystub);
405+
RegInterface_(lib, HK, guid, name, proxystub);
377406
If IsWin64 Then
378-
RegInterface_(lib, HKCU32, guid, name, proxystub);
407+
RegInterface_(lib, HK32, guid, name, proxystub);
379408
End;
380409
381410
// Enumeration registration (32/64bits Shared) :
@@ -391,12 +420,12 @@ Procedure RegRecord(Const lib : TNetLib; Const guid, typename: String);
391420
Var key: String;
392421
Begin
393422
key := 'Software\Classes\Record\' + guid;
394-
RegDeleteKeyIncludingSubkeys(HKCU, key);
423+
RegDeleteKeyIncludingSubkeys(HK, key);
395424
If Not IsUninstaller Then Begin
396-
RegString(HKCU, key, 'Class' , typename );
397-
RegString(HKCU, key, 'Assembly' , lib.FullName );
398-
RegString(HKCU, key, 'RuntimeVersion' , lib.Runtime );
399-
RegString(HKCU, key, 'CodeBase' , lib.PathDll );
425+
RegString(HK, key, 'Class' , typename );
426+
RegString(HK, key, 'Assembly' , lib.FullName );
427+
RegString(HK, key, 'RuntimeVersion' , lib.Runtime );
428+
RegString(HK, key, 'CodeBase' , lib.PathDll );
400429
End
401430
End;
402431
@@ -456,15 +485,15 @@ Procedure RegClass(Const lib : TNetLib; Const guid, progid, typename: String);
456485
Var key, sysdir: String;
457486
Begin
458487
key := 'Software\Classes\' + progid;
459-
RegDeleteKeyIncludingSubkeys(HKCU, key);
488+
RegDeleteKeyIncludingSubkeys(HK, key);
460489
If Not IsUninstaller Then Begin
461-
RegString(HKCU, key, '', progid);
462-
RegString(HKCU, key + '\CLSID', '', guid);
490+
RegString(HK, key, '', progid);
491+
RegString(HK, key + '\CLSID', '', guid);
463492
End
464493
465-
RegClsid(lib, HKCU, guid, progid, typename, '{sys}');
494+
RegClsid(lib, HK, guid, progid, typename, '{sys}');
466495
If IsWin64 Then
467-
RegClsid(lib, HKCU32, guid, progid, typename, '{syswow64}');
496+
RegClsid(lib, HK32, guid, progid, typename, '{syswow64}');
468497
End;
469498
470499
// TypeLib registration (32/64bits Shared) :
@@ -485,15 +514,15 @@ Procedure RegTypeLib(Const lib : TNetLib);
485514
Var key, skey : String;
486515
Begin
487516
key := 'Software\Classes\TypeLib\' + lib.Guid;
488-
RegDeleteKeyIncludingSubkeys(HKCU, key);
517+
RegDeleteKeyIncludingSubkeys(HK, key);
489518
If Not IsUninstaller Then Begin
490519
skey := key + '\' + lib.TypeVersion;
491-
RegString(HKCU, skey, '', lib.Description);
492-
RegString(HKCU, skey + '\FLAGS' , '' , '0' );
493-
RegString(HKCU, skey + '\HELPDIR' , '' , lib.Directory );
494-
RegString(HKCU, skey + '\0\win32' , '' , lib.PathTlb32 );
520+
RegString(HK, skey, '', lib.Description);
521+
RegString(HK, skey + '\FLAGS' , '' , '0' );
522+
RegString(HK, skey + '\HELPDIR' , '' , lib.Directory );
523+
RegString(HK, skey + '\0\win32' , '' , lib.PathTlb32 );
495524
If IsWin64 Then
496-
RegString(HKCU, skey + '\0\win64', '' , lib.PathTlb64 );
525+
RegString(HK, skey + '\0\win64', '' , lib.PathTlb64 );
497526
End
498527
End;
499528
@@ -510,8 +539,32 @@ Procedure RegisterAssembly();
510539
511540
Function InitializeSetup() : Boolean;
512541
Begin
513-
AssertFrameworkPresent('3.5');
514-
Result := True;
542+
ALL_USERS := HasPrivileges();
543+
InitRootKeys();
544+
//AssertFrameworkPresent('3.5');
545+
Result := True;
546+
End;
547+
548+
Function InitializeUninstall() : Boolean;
549+
var p : string;
550+
Begin
551+
ALL_USERS := GetPreviousData('AllUsers', '') = '1';
552+
InitRootKeys();
553+
Result := True;
554+
End;
555+
556+
Procedure RegisterPreviousData(PreviousDataKey: Integer);
557+
Begin
558+
SetPreviousData(PreviousDataKey, 'AllUsers', BoolToStr(ALL_USERS));
559+
End;
560+
561+
Procedure CurPageChanged(CurPageID: Integer);
562+
Begin
563+
If CurPageID = wpReady Then Begin
564+
Wizardform.ReadyMemo.Lines.Insert(0, 'Install folder:');
565+
Wizardform.ReadyMemo.Lines.Insert(1, ExpandConstant('{app}'));
566+
Wizardform.ReadyMemo.Lines.Insert(2, '');
567+
End;
515568
End;
516569
517570
Procedure CurStepChanged(CurStep: TSetupStep);

0 commit comments

Comments
 (0)