Question

i am trying to detect and install reportviewer 2005 for a .net 2.0 app i develop silently i already downloaded reportviewer 2005 redistributable installer and i have this script

The code to check if reportviewer is installed

/////////////////////////////////////////////////
// check if report viewer is installed
////////////////////////////////////////////////
function IsReportViewerInstalled(version: string): boolean;
//    'v2.0.50727'          .NET Framework 2.0

var
    key: string;
    install: cardinal;
    success: boolean;
       ErrorCode: Integer;
begin

    // installation all report viewer
    key := 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ReportViewer\' + version;

    success := RegQueryDWordValue(HKLM, key, 'Install', install);

    result := success and (install = 1);
end;

the code to detect and insall

if not IsReportViewerInstalled('v2.0.50727') then  begin
        ExtractTemporaryFile('ReportViewer.exe');
        Log(ExpandConstant('{tmp}\ReportViewer.exe'));
        if ShellExec('', ExpandConstant('{tmp}\ReportViewer.exe'), '','', SW_SHOWNORMAL, ewWaitUntilTerminated, ErrorCode) then  begin
              Result := True;
           end  else begin
    MsgBox('ReportViewer installation failed. '+SysErrorMessage(ErrorCode), mbError, MB_OK);
              Result := false;
        end;
end else  begin
    result := true;
end;

if i run the inno setup in my dev machine which has reportviewer installed, it still pops up reportviewer setup and it does no install silently

what am i doing wrong?

Edit

I fount that the parameter to install silen is ReportViewer.exe /q:a /c:"install.exe /q" how do i poass the /q:a /c:"install.exe /q" to the shell execute command?

Was it helpful?

Solution

There are 2 things that you should look at:

1st (thanks to TLama that spotted this issue)

The Key string - there is redundant HKEY_LOCAL_MACHINE\ in string Value.

You call HKLM branch in RegQueryDWordValue(HKLM, key, 'Install', install);

The correct Key should be:

key := 'SOFTWARE\Microsoft\ReportViewer\' + version;


2nd

You can call the silent install of ReportViewer if you know parameters for command line.

As you know that you shold use /q:a /c:"install.exe /q", you just simply add it in ShellExec function:

ShellExec('', ExpandConstant('{tmp}\ReportViewer.exe'), '/q:a /c:"install.exe /q"', ExpandConstant('{tmp}'), SW_HIDE, ewWaitUntilTerminated, ErrorCode)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top