安装VC可再发行文件和注册VC OCX的InnoSetup脚本会导致"RegSrv32失败,退出代码为0x1". [英] InnoSetup Script installing VC redistributables and registering VC OCX resulting in "RegSrv32 failed with exit code 0x1"

查看:81
本文介绍了安装VC可再发行文件和注册VC OCX的InnoSetup脚本会导致"RegSrv32失败,退出代码为0x1".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的InnoSetup脚本需要安装VC可再发行文件(vcredist_x86.exe),而且还需要依赖于Redist软件包注册OCX.我无法在regsrv32调用之前安装软件包,因此在原始系统上,它始终会导致"RegSrv32失败,退出代码0x1"错误(我可以忽略该错误并再次运行安装程序以正确注册OCX ).注册前如何确保已安装redist软件包?

My InnoSetup Script needs to install the VC redistributables (vcredist_x86.exe) but also registers an OCX relying on the redist package. I wasn't able to have the package installed prior to the regsrv32 call, so on a virgin system it always results in a "RegSrv32 failed with exit code 0x1" error (which I could ignore and run the setup again to correctly register the OCX). How can I make sure the redist package is installed before registering?

; 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

推荐答案

为方便起见,这是pastebin TLama所引用的代码:

For your convinience, here is the code from pastebin TLama referred me to:

[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;

这篇关于安装VC可再发行文件和注册VC OCX的InnoSetup脚本会导致"RegSrv32失败,退出代码为0x1".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆