I'm writing a function that will install a required component for my appliance, which is built upon PowerShell. If a specific version of PowerShell is not found, I want the installer to help the user install it. The problem I'm running into is how to appropriately call the offline installer for installation. Here is the code I have, which is a generic function (I am using the InnoSetup Dependency Installer):
function SmartExec(product : TProduct; var resultcode : Integer): boolean;
begin
if (LowerCase(Copy(product.File, Length(product.File) - 2, 3)) = 'exe') then begin
Result := Exec(product.File, product.Parameters, '', SW_SHOWNORMAL, ewWaitUntilTerminated, resultcode);
end else begin
Result := ShellExec('', product.File, product.Parameters, '', SW_SHOWNORMAL, ewWaitUntilTerminated, resultcode);
end;
end;
I have tried using the following:
function SmartExec(product : TProduct; var resultcode : Integer): boolean;
begin
if (LowerCase(Copy(product.File, Length(product.File) - 2, 3)) = 'exe') then begin
Result := Exec(product.File, product.Parameters, '', SW_SHOWNORMAL, ewWaitUntilTerminated, resultcode);
end else if (LowerCase(Copy(product.File, Length(product.File) - 2, 3)) = 'msu') then begin
Result := ShellExec('', 'wusa.exe ' + product.File, product.Parameters, '', SW_SHOWNORMAL, ewWaitUntilTerminated, resultcode);
end else begin
Result := ShellExec('', product.File, product.Parameters, '', SW_SHOWNORMAL, ewWaitUntilTerminated, resultcode);
end;
end;
When I compile and test the installer, I'm greeted with:
I am passing /quiet /norestart as parameters to the MSU file, which execute perfectly from a command prompt.
The installation file is downloaded to %tmp% for the current user, and I see the file.
Any help or comments?
