Scaramanga
Full Member | Редактировать | Профиль | Сообщение | ICQ | Цитировать | Сообщить модератору Доброго времени суток, сразу оговорюсь это моя первая попытка создать инсталятор. Вобщем суть проблемы такая: во время установки идет проверка на установленный Windows Managment Framework 4 и 5 версии, если они не установлены, то идет их закачка и затем установка. Вобщем проблема в следующем, MSU скачиваются нормально, затем идет установка WMF 4, тоже нормально, но следом при установк WMF 5 выскакивает ошибка Код: Не удается установить обновление Windows "Обновление для ОС Windows (KB3134760)" из-за ошибки: 2147956481 "Не найдена сборка, на которую имеется ссылка." (Командная строка: ""C:\Windows\system32\wusa.exe" "C:\Users\test\AppData\Local\Temp\is-MICPK.tmp\Win7AndW2K8R2-KB3134760-x64.msu" /quiet /norestart ") | При установки обновлений из командной строки подобных проблем нет, но в инно почему то устанавливаются только обновления по одному и следующее ставится только после перезагрузки. Код установки с обработкой кодов возврата: Код: function SmartExec(prod : TProduct; var ResultCode : Integer) : boolean; begin Exec('net', 'stop "wuauserv"', '', SW_HIDE, ewWaitUntilTerminated, ResultCode); Exec('net', 'start "wuauserv"', '', SW_HIDE, ewWaitUntilTerminated, ResultCode); if (LowerCase(Copy(prod.File,Length(prod.File)-2,3)) = 'exe') then begin Result := Exec(prod.File, prod.Parameters, '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode); end else begin Result := ShellExec('', prod.File, prod.Parameters, '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode); end; end; function PendingReboot : boolean; var names: String; begin if (RegQueryMultiStringValue(HKEY_LOCAL_MACHINE, 'SYSTEM\CurrentControlSet\Control\Session Manager', 'PendingFileRenameOperations', names)) then begin Result := true; end else if ((RegQueryMultiStringValue(HKEY_LOCAL_MACHINE, 'SYSTEM\CurrentControlSet\Control\Session Manager', 'SetupExecute', names)) and (names <> '')) then begin Result := true; end else begin Result := false; end; end; function InstallProducts: InstallResult; var ResultCode, i, productCount, finishCount: Integer; begin Result := InstallSuccessful; productCount := GetArrayLength(products); if productCount > 0 then begin DependencyPage := CreateOutputProgressPage(CustomMessage('depinstall_title'), CustomMessage('depinstall_description')); DependencyPage.Show; for i := 0 to productCount - 1 do begin if (products[i].InstallClean and (delayedReboot or PendingReboot())) then begin Result := InstallRebootRequired; break; end; DependencyPage.SetText(FmtMessage(CustomMessage('depinstall_status'), [products[i].Title]), ''); DependencyPage.SetProgress(i, productCount); if SmartExec(products[i], ResultCode) then begin //setup executed; ResultCode contains the exit code //MsgBox(products[i].Title + ' install executed. Result Code: ' + IntToStr(ResultCode), mbInformation, MB_OK); if (products[i].MustRebootAfter) then begin //delay reboot after install if we installed the last dependency anyways if (i = productCount - 1) then begin delayedReboot := true; end else begin Result := InstallRebootRequired; end; break; end else if (ResultCode = 0) then begin finishCount := finishCount + 1; end else if (ResultCode = 3010) then begin //ResultCode 3010: A restart is required to complete the installation. This message indicates success. delayedReboot := true; finishCount := finishCount + 1; end else begin Result := InstallError; break; end; end else begin //MsgBox(products[i].Title + ' install failed. Result Code: ' + IntToStr(ResultCode), mbInformation, MB_OK); Result := InstallError; break; end; end; //only leave not installed products for error message for i := 0 to productCount - finishCount - 1 do begin products[i] := products[i+finishCount]; end; SetArrayLength(products, productCount - finishCount); DependencyPage.Hide; end; end; function PrepareToInstall(var NeedsRestart: boolean): String; var i: Integer; s: string; begin delayedReboot := false; case InstallProducts() of InstallError: begin s := CustomMessage('depinstall_error'); for i := 0 to GetArrayLength(products) - 1 do begin s := s + #13 + ' ' + products[i].Title; end; Result := s; end; InstallRebootRequired: begin Result := products[0].Title; NeedsRestart := true; //write into the registry that the installer needs to be executed again after restart RegWriteStringValue(HKEY_CURRENT_USER, 'SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce', 'InstallBootstrap', ExpandConstant('{srcexe}')); end; end; end; | Проверка и запуск установки обновлений: Код: const KB2819745_url = 'http://download.microsoft.com/download/3/D/6/3D61D262-8549-4769-A660-230B67E15B25/Windows6.1-KB2819745-x64-MultiPkg.msu'; KB3134760_url = 'http://download.microsoft.com/download/2/C/6/2C6E1B4A-EBE5-48A6-B225-2D2058A9CEFB/Win7AndW2K8R2-KB3134760-x64.msu'; procedure KB2819745(); var version: string; begin RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine', 'PowerShellVersion', version); if version < '4.0' then begin //if (minwinspversion(5, 0, 2) and maxwinspversion(5, 0, 4)) then begin AddProduct('Windows6.1-KB2819745-x64-MultiPkg.msu', '/quiet /norestart', CustomMessage('KB2819745_title'), CustomMessage('KB2819745_size'), KB2819745_url,false,false); end; end; procedure KB3134760(); var version: string; begin RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine', 'PowerShellVersion', version); if version < '5.0' then begin //if (minwinspversion(5, 0, 2) and maxwinspversion(5, 0, 4)) then begin AddProduct('Win7AndW2K8R2-KB3134760-x64.msu', '/quiet /norestart', CustomMessage('KB3134760_title'), CustomMessage('KB3134760_size'), KB3134760_url,false,false); end; end; |
|