2015-06-03 2 views
1

My InnoSetup Script необходимо установить VC-распространяемые компоненты (vcredist_x86.exe), но также регистрирует OCX, полагающийся на пакет redist. Я не смог установить пакет до вызова regsrv32, поэтому в девственной системе всегда возникает ошибка «Ошибка RegSrv32 с кодом выхода 0x1» (который я мог бы игнорировать и снова запустить настройку, чтобы правильно зарегистрировать OCX). Как я могу убедиться, что пакет redist установлен до регистрации?InnoSetup Script, устанавливающий VC-дистрибутивы и регистрацию VC OCX, в результате чего «RegSrv32 не удалось с кодом выхода 0x1»

; Script generated by the Inno Setup Script Wizard. 
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! 

[Setup] 
AppName=MyApp 
AppVerName=MyApp v1.0 
DiskSpanning=no 
AppPublisher=me 
AppPublisherURL=http://www.example.com 
AppSupportURL=http://www.example.com 
AppUpdatesURL=http://www.example.com 
DefaultDirName={pf}\MyApp 
UsePreviousAppDir=yes 
DefaultGroupName=MyApp 
OutputBaseFilename=Setup 
OutputDir=.\MyAppSetup 
MinVersion=5.0 

[Tasks] 
Name: desktopicon; Description: Create a &desktop icon; GroupDescription: Additional icons:; MinVersion: 4,4 

[Files] 
;Source: "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT\msvcm90.dll"; DestDir: {app}; 
;Source: "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT\msvcp90.dll"; DestDir: {app}; 
;Source: "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT\msvcr90.dll"; DestDir: {app}; 
;Source: "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.ATL\atl90.dll"; DestDir: {app}; 
;Source: "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.MFC\mfc90.dll"; DestDir: {app}; 
;Source: "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.MFCLOC\MFC90DEU.dll"; DestDir: {app}; 
;Source: "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.OPENMP\vcomp90.dll"; DestDir: {app};  
Source: .\SystemFiles\vcredist_x86.exe; DestDir: {tmp}; Flags: deleteafterinstall; 
;-> [Run] !! 

Source: .\Release\MyApp.exe; DestDir: {app}; Flags: ignoreversion 
Source: .\Release\MyAppHelper.ocx; DestDir: {app}; Flags: regserver restartreplace 

[Icons] 
Name: {group}\EasyCash&Tax; Filename: {app}\MyApp.exe 
Name: {userdesktop}\EasyCash&Tax; Filename: {app}\MyApp.exe; MinVersion: 4,4; Tasks: desktopicon 

[Run] 
Filename: {tmp}\vcredist_x86.exe; Parameters: "/q:a /c:""VCREDI~3.EXE /q:a /c:""""msiexec /i vcredist.msi /qn"""" """; Flags: runhidden shellexec waituntilterminated; 
Filename: {app}\MyApp.exe; Description: Launch MyApp; Flags: nowait postinstall skipifsilent 
+0

код [Run] '' раздел обрабатывается после '[Files]'. Переместите повторную установку в функцию события PrepareToInstall. – TLama

+0

Но мне нужно временно установить файл на {tmp} \ vcredist_x86.exe для его запуска. Можете ли вы предоставить рабочий код в ответе? Это было бы круто. – thomiel

+0

Я думаю, что это может привести к запуску http://pastebin.com/33ZebFsF. – TLama

ответ

1

Для Вашего удобства, здесь код из Pastebin TLama называют меня:

[Setup] 
AppName=My Program 
AppVersion=1.5 
DefaultDirName={pf}\My Program 

[Files] 
Source: ".\SystemFiles\vcredist_x86.exe"; Flags: dontcopy 

[Code] 
function IsRuntimeInstalled: Boolean; 
begin 
    Result := False; 
    // here will be a statement that will check whether the runtime is installed 
    // and return True if so; see e.g. http://stackoverflow.com/q/11137424/960757 
end; 

function PrepareToInstall(var NeedsRestart: Boolean): string; 
var 
    ExitCode: Integer; 
begin 
    // if the runtime is not already installed 
    if not IsRuntimeInstalled then 
    begin 
    // extract the redist to the temporary folder 
    ExtractTemporaryFile('vcredist_x86.exe'); 
    // run the redist from the temp folder; if that fails, return from this handler the error text 
    if not Exec(ExpandConstant('{tmp}\vcredist_x86.exe'), '', '', SW_SHOW, ewWaitUntilTerminated, ExitCode) then 
    begin 
     // return the error text 
     Result := 'Setup failed to install VC++ runtime. Exit code: ' + IntToStr(ExitCode); 
     // exit this function; this makes sense only if there are further prerequisites to install; in this 
     // particular example it does nothing because the function exits anyway, so it is pointless here 
     Exit; 
    end; 
    end; 
end;