Article View: alt.pl.comp.lang.csharp
Article #9731Re: Instalator dla aplikacji .net
From: Rafal M
Date: Wed, 02 Nov 2005 14:44
Date: Wed, 02 Nov 2005 14:44
329 lines
12370 bytes
12370 bytes
Maciek wrote:
> Użytkownik "Rafal M" <rafalm1980@gazeta.pl> napisał w wiadomości
> news:dk6338$ign$1@inews.gazeta.pl...
>
>>Maciek wrote:
>>
>>>Czy istnieje instalator, który potrafić wykryć brak środowiska Microsoft
>>>.NET Framework w systemie i ewentualnie "zaproponować" jego instalacje w
>>>czasie procesu instalacji aplikacji?
>>>
>>>Zależałoby mi na jak najtańszym rozwiązaniu, które jednak nadawało by się
>>>do zastosowań komercyjnych.
>>>
>>>Macius
>>
>>InnoSetup + ISTool + skrypt wykrywajacy .NET, rozwiazanie calkowicie
>>darmowe ... :)
>
>
> Próbowałem wcześniej coś kombinować z InnoSetup(całkiem przyjemny), ale nie
> wiedziałem jak zabrać się za skrypt wykrywający .NET. W google znalazłem
> kilka stron na ten temat, ale nie bardzo wiem co wybrać. Czy mógłbyś
> podpowiedzieć coś na temat samego skryptu
>
>
http://www.codeproject.com/dotnet/dotnetinstallerforinno.asp
http://www.codeproject.com/dotnet/dotnetinstallerforinno/Article_src.zip
#include "C:\Program Files\ISTool 4\isxdl.iss"
[Setup]
AppName=dotnet Framework 1.1
DisableProgramGroupPage=true
Uninstallable=false
DirExistsWarning=no
CreateAppDir=false
OutputDir=release
OutputBaseFilename=dotnet
SourceDir=.
ShowTasksTreeLines=false
AppCopyright=Copyright Hawkeye Technologies
AppVerName=Framework Installer
PrivilegesRequired=admin
DisableStartupPrompt=true
[_ISTool]
EnableISX=true
[Tasks]
[Files]
[Icons]
[Run]
Filename: {ini:{tmp}\dep.ini,install,sp6a}; Parameters: /U
/X:{tmp}\sp6a; Description: NT4 SP6a Extract; StatusMsg: Extracting NT4
Service Pack 6a Files...; Flags: skipifdoesntexist
Filename: {tmp}\sp6a\update\update.exe; Parameters: -u -z; Description:
NT4 SP6a Install; StatusMsg: Installing NT4 Service Pack 6a...; Flags:
skipifdoesntexist
Filename: {ini:{tmp}\dep.ini,install,ie}; Description: IE 6; StatusMsg:
Installing Internet Explorer 6... (This may take a few minutes); Flags:
skipifdoesntexist; Parameters: "/Q /C:""ie6wzd /QU /R:N /S:#e"""
Filename: {ini:{tmp}\dep.ini,install,mdac}; Parameters: "/Q /C:""setup
/QNT"""; Description: MDAC 2.8; StatusMsg: Installing Microsoft Data
Access Components 2.8... (This may take a few minutes); Flags:
skipifdoesntexist
Filename: {ini:{tmp}\dep.ini,install,jet}; Description: JET 4;
StatusMsg: Installing Jet 4.0 Database Components...; Flags:
skipifdoesntexist; Parameters: /Q
Filename: {ini:{tmp}\dep.ini,install,dotnet11Redist}; Parameters: "/Q
/T:{tmp}\dotnetfx /C:""install /q"""; Description: .NET 1.1 Install;
Flags: skipifdoesntexist; StatusMsg: Installing Microsoft .NET 1.1...
(This may take a few minutes)
[Code]
var
iePath, sp6aPath, mdacPath, jetPath, dotnet11RedistPath: string;
downloadNeeded: boolean;
exclusiveNeeded: boolean;
// SP6a must be installed exclusively or IE 5 install will fail.
// IE 5 must be installed exclusively or netfx will error with:
"urlmon.dll entry point error"
memoDependenciesNeeded: string;
const
ieURL =
'http://download.microsoft.com/download/ie6sp1/finrel/6_sp1/W98NT42KMeXP/EN-US/ie6setup.exe';
sp6aURL =
'http://download.microsoft.com/download/winntsp/SP/6.0a-128/NT4/EN-US/sp6i386.exe';
mdacURL =
'http://download.microsoft.com/download/c/d/f/cdfd58f1-3973-4c51-8851-49ae3777586f/MDAC_TYP.EXE';
jetURL =
'http://download.microsoft.com/download/e/8/c/e8c5729c-d90a-4d15-bdc1-cbc9eae82924/Jet40SP7_9xNT.exe';
dotnet11RedistURL =
'http://download.microsoft.com/download/a/a/c/aac39226-8825-44ce-90e3-bf8203e74006/dotnetfx.exe';
constIsService = false;
constIISRequired = false;
function InitializeSetup(): Boolean;
var
sRet: string;
nRet: integer;
begin
Result := true;
// Check for required IIS installation
if constIISRequired then begin
if not RegKeyExists(HKLM,
'SYSTEM\CurrentControlSet\Services\W3SVC\Security') then begin
MsgBox('Microsoft IIS must be installed before setup can
continue. Please install IIS and run Setup again.', mbError, MB_OK);
Result := false;
exit;
end;
end;
// Check for required SP6a installation
RegQueryStringValue(HKLM, 'Software\Microsoft\Windows
NT\CurrentVersion', 'CurrentVersion', sRet);
if sRet < '5' then begin
if not RegKeyExists(HKLM, 'Software\Microsoft\Windows
NT\CurrentVersion\Hotfix\Q246009') then begin
MsgBox('Windows NT4 Service Pack 6a must be installed before
Setup can install the application. Setup will attempt to install SP6a
for you. After the computer reboots, please run Setup again.',
mbInformation, MB_OK);
exclusiveNeeded := true;
memoDependenciesNeeded := memoDependenciesNeeded + ' NT4
Service Pack 6a' #13;
sp6aPath := ExtractFileDrive(ExpandConstant('{src}')) +
'\dependencies\sp6i386.exe';
if not FileExists(sp6aPath) then begin
sp6aPath := ExpandConstant('{tmp}\sp6i386.exe');
if not FileExists(sp6aPath) then begin
isxdl_AddFile(sp6aURL, sp6aPath);
downloadNeeded := true;
end;
end;
end;
SetIniString('install', 'sp6a', sp6aPath,
ExpandConstant('{tmp}\dep.ini'));
end;
// Check for required IE installation
// Note that if IE 6 is downloaded, the express setup will be
downloaded, however it is the same
// ie6setup.exe that would be available in the ie6full folder. The
only difference is that the
// user will be presented with an option as to where to download IE 6
and a progress dialog.
// Most common components will still be installed automatically.
sRet := '';
RegQueryStringValue(HKLM, 'Software\Microsoft\Internet Explorer',
'Version', sRet);
if (not exclusiveNeeded) and (sRet < '5') then begin
exclusiveNeeded := true;
MsgBox('Internet Explorer 6 must be installed before Setup can
install the application. Setup will attempt to install IE 6 for you.
After the computer reboots, please run Setup again.', mbInformation, MB_OK);
memoDependenciesNeeded := memoDependenciesNeeded + ' Internet
Explorer 6' #13;
iePath := ExtractFileDrive(ExpandConstant('{src}')) +
'\dependencies\ie6full\ie6setup.exe';
if not FileExists(iePath) then begin
iePath := ExpandConstant('{tmp}\ie6setup.exe');
if not FileExists(iePath) then begin
isxdl_AddFile(ieURL, iePath);
downloadNeeded := true;
end;
end;
SetIniString('install', 'ie', iePath, ExpandConstant('{tmp}\dep.ini'));
end;
// Check for required MDAC installation
sRet := '';
RegQueryStringValue(HKLM, 'Software\Microsoft\DataAccess',
'FullInstallVer', sRet);
if (not exclusiveNeeded) and (sRet < '2.7') then begin
memoDependenciesNeeded := memoDependenciesNeeded + ' Microsoft
Data Access Components 2.8' #13;
mdacPath := ExtractFileDrive(ExpandConstant('{src}')) +
'\dependencies\MDAC_TYP.EXE';
if not FileExists(mdacPath) then begin
mdacPath := ExpandConstant('{tmp}\MDAC_TYP.EXE');
if not FileExists(mdacPath) then begin
isxdl_AddFile(mdacURL, mdacPath);
downloadNeeded := true;
end;
end;
SetIniString('install', 'mdac', mdacPath,
ExpandConstant('{tmp}\dep.ini'));
end;
// Check for required Jet installation
// Jet is not included in MDAC 2.5+. It will be needed on NT4
installations.
if (not exclusiveNeeded) and (not RegKeyExists(HKLM,
'Software\Microsoft\Jet\4.0')) then begin
memoDependenciesNeeded := memoDependenciesNeeded + ' Jet 4.0
Database Components' #13;
jetPath := ExtractFileDrive(ExpandConstant('{src}')) +
'\dependencies\Jet40SP7_9xNT.exe';
if not FileExists(jetPath) then begin
jetPath := ExpandConstant('{tmp}\Jet40SP7_9xNT.exe');
if not FileExists(jetPath) then begin
isxdl_AddFile(jetURL, jetPath);
downloadNeeded := true;
end;
end;
SetIniString('install', 'jet', jetPath,
ExpandConstant('{tmp}\dep.ini'));
end;
// Check for required netfx 1.1 installation
if (not exclusiveNeeded) and (not RegKeyExists(HKLM,
'Software\Microsoft\.NETFramework\policy\v1.1')) then begin
memoDependenciesNeeded := memoDependenciesNeeded + ' .NET
Framework 1.1' #13;
dotnet11RedistPath := ExtractFileDrive(ExpandConstant('{src}')) +
'\dependencies\dotnetfx.exe';
if not FileExists(dotnet11RedistPath) then begin
dotnet11RedistPath := ExpandConstant('{tmp}\dotnetfx.exe');
if not FileExists(dotnet11RedistPath) then begin
isxdl_AddFile(dotnet11RedistURL, dotnet11RedistPath);
downloadNeeded := true;
end;
end;
SetIniString('install', 'dotnet11Redist', dotnet11RedistPath,
ExpandConstant('{tmp}\dep.ini'));
end;
sRet := '';
RegQueryStringValue(HKLM, 'Software\Microsoft\Internet Explorer',
'Version', sRet);
if downloadNeeded and (sRet < '3') then begin
// Downloads are needed and isxdl can't initialize to download
them, abort
Result := false;
if FileExists(iePath) then begin
MsgBox('Internet Explorer 5 (or later) must be installed manually
before Setup can continue.' #13#13 'Setup will now exit and begin the IE
6 installation.', mbInformation, MB_OK);
InstExec(iePath, '', '', false, false, 0, nRet);
end else begin
if MsgBox('Internet Explorer 5 (or later) must be installed
manually before Setup can continue.' #13#13 'Would you like to visit the
download site now?', mbConfirmation, MB_OKCANCEL) = IDOK then
InstShellExec('http://www.microsoft.com/ie', '', '',
SW_SHOWNORMAL, nRet);
end;
end;
end;
function NextButtonClick(CurPage: Integer): Boolean;
var
hWnd: Integer;
begin
Result := true;
if CurPage = wpReady then begin
hWnd := StrToInt(ExpandConstant('{wizardhwnd}'));
// don't try to init isxdl if it's not needed because it will error
on < ie 3
if downloadNeeded then
if isxdl_DownloadFiles(hWnd) = 0 then Result := false;
end;
end;
function SkipCurPage(CurPage: Integer): Boolean;
begin
if (CurPage = wpSelectDir) and exclusiveNeeded then Result := true;
end;
function UpdateReadyMemo(Space, NewLine, MemoUserInfoInfo, MemoDirInfo,
MemoTypeInfo, MemoComponentsInfo, MemoGroupInfo, MemoTasksInfo: String):
String;
var
s: string;
begin
if memoDependenciesNeeded <> '' then s := s + 'Dependencies to
install:' + NewLine + memoDependenciesNeeded + NewLine;
s := s + MemoDirInfo + NewLine + NewLine;
Result := s
end;
function IsService: Boolean;
begin
if constIsService then Result := true;
end;
function IsServiceAndNotExclusiveNeeded: Boolean;
begin
if constIsService then if not exclusiveNeeded then Result := true;
end;
function IsApplication: Boolean;
begin
if not constIsService then Result := true;
end;
function IsApplicationAndNotExclusiveNeeded: Boolean;
begin
if not constIsService then if not exclusiveNeeded then Result := true;
end;
function IsNotExclusiveNeeded: Boolean;
begin
if not exclusiveNeeded then Result := true;
end;
function IsNotMAMRunning: Boolean;
begin
if FindWindowByWindowName('Multimax Addon Manager') = 0 then Result
:= true;
end;
Technical Details
Message-ID:
<dkajcv$dvf$1@inews.gazeta.pl>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!not-for-mailReferences:
<dk62og$ihi$1@inews.gazeta.pl> <dk6338$ign$1@inews.gazeta.pl> <dk8l4q$e9q$1@inews.gazeta.pl>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!not-for-mail From: Rafal M <rafalm1980@gazeta.pl> Newsgroups: alt.pl.comp.lang.csharp Subject: Re: Instalator dla aplikacji .net Date: Wed, 02 Nov 2005 15:44:45 +0100 Organization: "Portal Gazeta.pl -> http://www.gazeta.pl" Lines: 330 Message-ID: <dkajcv$dvf$1@inews.gazeta.pl> References: <dk62og$ihi$1@inews.gazeta.pl> <dk6338$ign$1@inews.gazeta.pl> <dk8l4q$e9q$1@inews.gazeta.pl> NNTP-Posting-Host: user0.167.udn.pl Mime-Version: 1.0 X-Trace: inews.gazeta.pl 1130942688 14319 82.139.0.167 (2 Nov 2005 14:44:48 GMT) X-Complaints-To: usenet@agora.pl NNTP-Posting-Date: Wed, 2 Nov 2005 14:44:48 +0000 (UTC) In-Reply-To: <dk8l4q$e9q$1@inews.gazeta.pl> X-Accept-Language: en-us, en X-User: rafalm1980 User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit