It's been a while, but I'm back. Not in Cambridge anymore but Oxford. Still MSI'ing but on a somewhat larger scale.
Below is a little inno installer (5.1.4) script that was written to install a couple of system device drivers to to 32bit and 64bit platforms.
[Setup]
AppName={code:GetAppName'Sophos Drivers'}
AppVerName=Sophos Drivers ( ** INTERNAL USE ONLY ** )
Compression=lzma/ultra
SolidCompression=true
UsePreviousAppDir=false
UsePreviousGroup=false
UsePreviousSetupType=false
UsePreviousTasks=false
ShowLanguageDialog=yes
WizardImageStretch=false
DirExistsWarning=yes
CreateAppDir=false
DisableProgramGroupPage=true
Uninstallable=false
RestartIfNeededByRun=false
AllowCancelDuringInstall=false
InternalCompressLevel=ultra
MergeDuplicateFiles=false
VersionInfoDescription=Sophos Drivers
VersionInfoVersion=3.3.0.100
VersionInfoCompany=Sophos plc
VersionInfoTextVersion=3.3.0.100
WizardImageFile=compiler:WizModernImage-IS.bmp
WizardSmallImageFile=compiler:WizModernSmallImage-IS.bmp
;Only allow this setup to run on NT based OS's only
MinVersion=0,4.0.1381
; "ArchitecturesInstallIn64BitMode=x64 ia64" requests that the install
; be done in "64-bit mode" on x64 & Itanium, meaning it should use the
; native 64-bit Program Files directory and the 64-bit view of the
; registry. On all other architectures it will install in "32-bit mode".
ArchitecturesInstallIn64BitMode=x64 ia64
[Files]
;Running on x64
Source: C:\Driver Test\INNO\WinXP_AMD64\SAVONACCESSCONTROL.sys; DestDir: {tmp}; Check: IsX64
Source: C:\Driver Test\INNO\WinXP_AMD64\savonaccessdriv.inf; DestDir: {tmp}; Check: IsX64
Source: C:\Driver Test\INNO\WinXP_AMD64\SAVONACCESSFILTER.sys; DestDir: {tmp}; Check: IsX64
;Running on Itanium
Source: C:\Driver Test\INNO\WinXP_IA64\SAVONACCESSCONTROL.sys; DestDir: {tmp}; Check: IsIA64
Source: C:\Driver Test\INNO\WinXP_IA64\savonaccessdriv.inf; DestDir: {tmp}; Check: IsIA64
Source: C:\Driver Test\INNO\WinXP_IA64\SAVONACCESSFILTER.sys; DestDir: {tmp}; Check: IsIA64
;Windows 2000 base thru to Windows 2000 SP3
Source: C:\Driver Test\INNO\Win2K\SAVONACCESSCONTROL.sys; DestDir: {tmp}; OnlyBelowVersion: 0,5.0.2195sp3; MinVersion: 0,4.0.1381
Source: C:\Driver Test\INNO\Win2K\savonaccessdriv.inf; DestDir: {tmp}; OnlyBelowVersion: 0,5.0.2195sp3; MinVersion: 0,4.0.1381
Source: C:\Driver Test\INNO\Win2K\SAVONACCESSFILTER.sys; DestDir: {tmp}; OnlyBelowVersion: 0,5.0.2195sp3; MinVersion: 0,4.0.1381
;Windows XP onwards
Source: C:\Driver Test\INNO\WinXP_i386\SAVONACCESSCONTROL.sys; DestDir: {tmp}; MinVersion: 0,5.01.2600
Source: C:\Driver Test\INNO\WinXP_i386\savonaccessdriv.inf; DestDir: {tmp}; MinVersion: 0,5.01.2600
Source: C:\Driver Test\INNO\WinXP_i386\SAVONACCESSFILTER.sys; DestDir: {tmp}; MinVersion: 0,5.01.2600
[Run]
;Win95 ONLY
;Filename: {win}\rundll.exe; Parameters: setupx.dll,InstallHinfSection DefaultInstall 132 {tmp}\savonaccessdriv.inf; MinVersion: 1, 0
;Filename: {win}\rundll.exe; Parameters: setupx.dll,InstallHinfSection DefaultUninstall 132 {tmp}\savonaccessdriv.inf; MinVersion: 1, 0
;All Other OS's
Filename: {sys}\rundll32.exe; Parameters: setupapi,InstallHinfSection DefaultInstall 132 {tmp}\savonaccessdriv.inf; MinVersion: 0, 1; Check: IsInstall; Flags: runhidden
Filename: {sys}\rundll32.exe; Parameters: setupapi,InstallHinfSection DefaultUninstall 132 {tmp}\savonaccessdriv.inf; MinVersion: 0,1; Check: IsUninstall; Flags: runhidden
[Messages]
AboutSetupNote=Sophos home page:%nhttp://www.sophos.com/
BeveledLabel=Sophos
[Code]
program Setup;
var
bUninstall: Boolean;
sAppName: String;
function IsX64: Boolean;
begin
Result := Is64BitInstallMode and (ProcessorArchitecture = paX64);
end;
function IsIA64: Boolean;
begin
Result := Is64BitInstallMode and (ProcessorArchitecture = paIA64);
end;
function GetAppName(Param: String): String;
var
Version: TWindowsVersion;
begin
//This function is called at startup by the [Setup] section ( See AppName={code:GetAppName'Sophos Driver'} )
GetWindowsVersionEx(Version);
case ProcessorArchitecture of
paX86:
begin
case Version.Major of
4:
begin
Result := 'Sophos NT4 x86 Drivers';
end;
5:
begin
case Version.Minor of
0:
begin
Result := 'Sophos Windows 2000 Drivers';
end;
1:
begin
Result := 'Sophos Windows XP (x86) Drivers';
end;
else
//Higher than 2 = not yet released by MS as of June 2005
Result := 'Unrecognized_OS';
end;
end;
end;
end;
paX64:
begin
case Version.Minor of
2:
begin
Result := 'Sophos Windows 2003 (x64) Drivers';
end;
else
//Higher than 2 = not yet released by MS as of June 2005
Result := 'Unrecognized_OS';
end;
end;
paIA64: Result := 'Sophos Itanium Drivers';
paUnknown: Result := 'Unrecognized_Architecture';
end;
//Set the public var
sAppName:=Result
end;
function IsInstall: Boolean;
begin
if (pos('uninstall', Lowercase(GetCmdTail()) ) = 0) then begin
Result := True;
end else begin
Result := False;
end;
end;
function IsUninstall: Boolean;
begin
//If we (setup.exe) were passed UNINSTALL as a command line parameter,
//uninstall the drivers! DOH!
if (pos('uninstall', Lowercase(GetCmdTail()) ) <> 0) then begin
bUninstall := True;
Result := True;
end else begin
bUninstall := False;
Result := False;
end;
end;
procedure CurPageChanged(CurPageID: Integer);
var
sUninstall:String;
//here we need to change the text of the UI to be an 'uninstall UI'
begin
if not bUninstall then begin
{
NOT USED
case CurPageID of
wpWelcome:
begin
MsgBox('wpWelcome' + #13 + sAppName, mbError, MB_OK);
Exit;
end;
wpReady:
begin
MsgBox('wpReady' + #13 + sAppName, mbError, MB_OK);
end;
end;
}
end else begin
case CurPageID of
wpWelcome:
begin
WizardForm.WELCOMELABEL1.Caption := SetupMessage(msgUninstallAppTitle) + ' ' + sAppName;
WizardForm.WELCOMELABEL2.Caption := '';
end;
wpReady:
begin
sUninstall := ExpandConstant('{cm:UninstallProgram}');
if (Pos('%1', sUninstall) > 0) then begin
StringChange(sUninstall,'%1', '' );
end;
WizardForm.NextButton.Caption := SetupMessage(msgUninstallAppTitle);
WizardForm.READYLABEL.Caption := SetupMessage(msgUninstallAppTitle) + ' ' + sAppName;
WizardForm.PAGENAMELABEL.Caption := SetupMessage(msgUninstallAppTitle) //Bold top label
WizardForm.PAGEDESCRIPTIONLABEL.Caption := ''; //normal top label
end;
end;
end;
BringToFrontAndRestore;
end;
Function InitializeSetup(): Boolean;
begin
if CheckForMutexes('SOPHOSDRIVER') then begin
SuppressibleMsgBox('Sophos Driver Setup is already running!' + #13 + 'Only one copy of this program may run at one time.' + #13 + 'Allow the other running program to complete first.' + #13 + #13 + 'This instance will now close.', mbError, MB_OK, MB_OK);
Result := False;
Exit;
end else
CreateMutex('SOPHOSDRIVER');
Result := True;
if Length(GetCmdTail()) > 0 then begin
if (pos('?', Lowercase(GetCmdTail()) ) <> 0) then begin
SuppressibleMsgBox('This setup has only one valid command line parameter.' + #13#13 + 'UNINSTALL - removes the installed drivers', mbCriticalError, MB_OK, MB_OK);
Result := False;
Exit;
end;
end
IsUninstall
end;
procedure InitializeWizard();
begin
{sAppName is set in function GetAppName, and that is called from the [Setup] section, and that
is called after InitializeSetup, so cannot put the following code in there. This function is called after
the [Setup] section has finished loading, but before the UI is shown.}
if sAppName = 'Unrecognized_Architecture' then begin
RaiseException('The processor architecture of this computer has not been recognized.');
end;
if sAppName = 'Unrecognized_OS' then begin
RaiseException('The OS of this computer (' + GetWindowsVersionString + ') has not been recognized.');
end;
end;