2

我得到了这条线:

[Files]
Source: "vc_redist.x64.exe"; DestDir: {tmp}; Flags: deleteafterinstall

[Run]
Filename: {tmp}\vc_redist.x64.exe; Parameters: "/install /passive /norestart"; 
 StatusMsg: Installing VC++ 2015 Redistributables...
Filename: "{app}\{#MyAppExeName}"; 
 Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; 
 Flags: nowait postinstall skipifsilent

但是有问题,因为它从不安装 vc_redist.64.exe

编辑:这是日志。

[21:25:22,783]   *** Setup started
[21:25:29,299]   Setup version: Inno Setup version 5.5.9 (a)
[21:25:29,300]   Original Setup EXE: C:\Users\Justo\Desktop\pruebas\ANdi.exe
[21:25:29,301]   Setup command line: /SL5="$200EAA,183958979,53760,C:\Users\Justo\Desktop\pruebas\ANdi.exe" /SPAWNWND=$300F00 /NOTIFYWND=$170EEE /DEBUGWND=$1B60C36 
[21:25:29,302]   Windows version: 10.0.14393  (NT platform: Yes)
[21:25:29,303]   64-bit Windows: Yes
[21:25:29,304]   Processor architecture: x64
[21:25:29,305]   User privileges: Administrative
[21:25:29,307]   64-bit install mode: No
[21:25:34,891]   Created temporary directory: C:\Users\Justo\AppData\Local\Temp\is-GVDUU.tmp
[21:25:44,315]   Starting the installation process.
[21:25:44,319]   Creating directory: C:\Program Files (x86)\ANdi
[21:25:44,321]   Directory for uninstall files: C:\Program Files (x86)\ANdi
[21:25:44,322]   Creating new uninstall log: C:\Program Files (x86)\ANdi\unins000.dat

[21:25:44,327]   -- File entry --
[21:25:44,329]   Dest filename: C:\Program Files (x86)\ANdi\unins000.exe
[21:25:44,332]   Time stamp of our file: 2016-12-26 21:25:29.248
[21:25:44,334]   Installing the file.
[21:25:44,337]   Uninstaller requires administrator: Yes
[21:25:44,462]   Successfully installed the file.

[21:25:44,471]   -- File entry --
[21:25:44,473]   Dest filename: C:\Program Files (x86)\ANdi\ANDI.exe
[21:25:44,475]   Time stamp of our file: 2016-12-23 15:54:56.000
[21:25:44,476]   Installing the file.
[21:25:50,568]   Successfully installed the file.

[21:25:50,578]   -- File entry --
[21:25:50,580]   Dest filename: C:\Program Files (x86)\ANdi\JPLEPH.exe
[21:25:50,582]   Time stamp of our file: 2016-11-03 20:07:04.000
[21:25:50,584]   Installing the file.
[21:25:50,605]   Successfully installed the file.

[21:25:50,616]   -- File entry --
[21:25:50,618]   Dest filename: C:\Program Files (x86)\ANdi\JPLEPH.430
[21:25:50,620]   Time stamp of our file: 2016-10-14 12:42:00.000
[21:25:50,621]   Installing the file.
[21:26:00,566]   Successfully installed the file.

[21:26:00,575]   -- File entry --
[21:26:00,577]   Dest filename: C:\WINDOWS\Fonts\astro.ttf
[21:26:00,585]   Time stamp of our file: 1996-09-03 03:00:00.000
[21:26:00,587]   Dest file exists.
[21:26:00,588]   Skipping due to "onlyifdoesntexist" flag.

[21:26:00,600]   -- File entry --
[21:26:00,602]   Dest filename: C:\Users\Justo\AppData\Local\Temp\is-
GVDUU.tmp\vc_redist.x64.exe
[21:26:00,604]   Time stamp of our file: 2016-12-26 18:52:40.000
[21:26:00,605]   Installing the file.
[21:26:02,005]   Successfully installed the file.

[21:26:02,014]   -- Icon entry --
[21:26:02,016]   Dest filename: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\ANdi.lnk
[21:26:02,018]   Creating the icon.
[21:26:02,048]   Successfully created the icon.

[21:26:02,057]   -- Icon entry --
[21:26:02,059]   Dest filename: C:\Users\Public\Desktop\ANdi.lnk
[21:26:02,061]   Creating the icon.
[21:26:02,073]   Successfully created the icon.
[21:26:02,087]   Installation process succeeded.

[21:26:02,099]   -- Run entry --
[21:26:02,100]   Run as: Current user
[21:26:02,102]   Type: Exec
[21:26:02,103]   Filename: C:\Users\Justo\AppData\Local\Temp\is-GVDUU.tmp\vc_redist.x64.exe
[21:26:02,105]   Parameters: /install /passive /norestart
[21:26:02,857]   Process exit code: 1638
[21:26:02,860]   Need to restart Windows? No

[21:26:05,117]   -- Run entry --
[21:26:05,119]   Run as: Original user
[21:26:05,121]   Type: Exec
[21:26:05,122]   Filename: C:\Program Files (x86)\ANdi\ANDI.exe
[21:26:05,388]   Deinitializing Setup.
[21:26:05,430]   *** Setup exit code: 0

你可以帮帮我吗?非常感谢。

4

1 回答 1

2

我很感激答案迟到了,但这有很多观点,所以我希望这些信息对某人有所帮助。关键部分是功能DoVcredistInstall,它在 Inno 安装步骤中的使用CurStepChanged

以下是我使用的 Inno Setup 脚本的一些片段:-

function DoVcredistInstall():Integer;
var
  ResultCode: Integer;
  strResultCode: String;

begin
  Log('Inside DoVcredistInstall');
  ResultCode := 0;
  NeedRestartFlag := False;

  if RegKeyExists(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{7e9fae12-5bbf-47fb-b944-09c49e75c061}') then
    Begin
      Log('REDIST INSTALLED');
    End
  else                                               
    Begin
      ProgressPage := CreateOutputProgressPage('Microsoft Redistributables Check');

      ProgressPage.Show;

      ExtractTemporaryFile('VC_redist.x86.exe');

      Exec(ExpandConstant('{tmp}\VC_redist.x86.exe'), '/q /norestart', '', SW_SHOW, ewWaitUntilTerminated, ResultCode);

      strResultCode := IntToStr(ResultCode);

      ProgressPage.Hide;
    End;

  Log('VCREDIST RETURN CODE = ' + strResultCode);
  Result := ResultCode;
end;

{ Is app running check }
function IsAppRunning(FileName : string): Boolean;
var
  FSWbemLocator: Variant;
  FWMIService : Variant;
  FWbemObjectSet: Variant;
begin
  Result := false;
  FSWbemLocator := CreateOleObject('WBEMScripting.SWBEMLocator');
  FWMIService := FSWbemLocator.ConnectServer('', 'root\CIMV2', '', '');
  FWbemObjectSet := FWMIService.ExecQuery(Format('SELECT Name FROM Win32_Process Where Name="%s"',[FileName]));
  Result := (FWbemObjectSet.Count > 0);
  FWbemObjectSet := Unassigned;
  FWMIService := Unassigned;
  FSWbemLocator := Unassigned;

  if Result = TRUE then
    begin
      msgBox('App Already Running Error',mbInformation,MB_OK);
    end;

end;

{ Look for the specified Window open }
function myFindWindow(WindowData: String): Boolean;
var
 hWND: integer;
begin
  hWND := FindWindowByWindowName(WindowData);

  if hWND > 0 then 
    begin
      MsgBox('Application Window Open Error',mbInformation,MB_OK);

      Result := True;
    end
end;

procedure CurStepChanged(CurStep: TSetupStep);
var
  VcredistResultCode: Integer;
  strVcredistResultCode: String;

  begin
    if CurStep = ssInstall then
      begin
        NeedRestartFlag := False;
        VcredistResultCode := DoVcredistInstall();
        strVcredistResultCode := 'CurStepChanged VcredistResultCode = ' + IntToStr(VcredistResultCode);
        Log(strVcredistResultCode);
        if (VcredistResultCode = 1641) OR (VcredistResultCode = 3010) then { runtime install restart required, 1641=reboot initiated by vcredist, 3010 = success but reboot required }
          begin
            NeedRestartFlag := True;
          end
        else
          begin
            if (VcredistResultCode <> 0) AND (VcredistResultCode <> 1638) then { runtime install failed 0=success, 1638=new version already installed, anything else = failed }
              begin
                MsgBox('Install error = ' + strVcredistResultCode',mbInformation,MB_OK);
                Abort();  { abort }
              end
          end
     end;
  end;

function NeedRestart(): Boolean;
begin
  if NeedRestartFlag then
  begin
    Log('Need restart');
    Result := True;
  end
    else
  begin
    Log('Do not need restart');
    Result := False;
  end;
end;

这会检查运行时的一个特定版本,因此您可能必须更改关键数据以反映您的版本。我的数据来自:
检测是否安装了 Visual C++ Redistributable for Visual Studio 2012

于 2019-10-31T13:23:24.700 回答