I want to install the Microsoft SQL Server Native Client in a self-written installer. The database driver is to be installed once on first launch.
My problem is that on some computers, the driver installation is not performed if my program is not running as administrator.
If my program is not running as an administrator, I get with 'runas' in ShellExecute Admin rights. The request for admin rights appears, but then on some computers the installation of the driver is not being executed.
function shellExec (APath, AParameter: String) : Boolean;
rslt := ShellExecute (0, pChar('runas'), pChar(APath), pChar(AParameter), pChar(''), SW_SHOWNORMAL);
result := ( rslt > 32 );
end;
shellExec('msiexec.exe', '-i' + MsiInstaller + ' /qn IACCEPTSQLNCLILICENSETERMS=YES');
// MsiInstaller = Path to NativeClient-Installer
Then I give the program with Sleep (20000) 20 seconds time, so that the installation can be performed. In normal fast computers, the installation takes 2-4 seconds, so the generously dimensioned 20 seconds should not be a problem.
For clarity, I have the error evaluation off "rslt" omitted here in the post. Of course its added in my code. But I do not get any error codes.
Has anyone any idea why the installation works when the program is started with admin rights, but not when it is requesting Admin rights themselves?
If the program is started with admin rights, no second message is shown for the admin rights for the driver installation.
Question: How to ensure that the installer is always executed, and my program does not need to be started with admin rights?