OOTB way to check for admin permissions before run

2019-08-14 17:25发布

问题:

I'm creating an installer for a 3rd Party ActiveX DLL running in IE7-9 on XP-Win7. The MSI should perform the following:

  1. Check for admin permissions. Notify the user and exit if insufficient permissions.
  2. Check for previous version. If it exists unregister or overwrite it.
  3. Install the DLL with vsdrfCOM so that it is recognized in the IE add-on menu.

For (3), I set the vsdrfCOM but it didn't seem to work. I don't see an OOTB way to perform (1) or (2). Is that correct or is there an OOTB way?

Thanks.

回答1:

Check for admin permissions. Notify the user and exit if insufficient permissions.

This is not really supported because of the way Windows UAC works on newer Windows versions. Basically, any user can become an Administrator through elevation. Also, even Administrators don't have full privileges unless they elevate.

The solution is to decide on an installation type (per-user or per-machine) and let Windows Installer handle permissions and elevation.

Check for previous version. If it exists unregister or overwrite it.

This is done automatically when using major upgrades.

Install the DLL with vsdrfCOM so that it is recognized in the IE add-on menu.

I don't think this is enough. The installation process should register your files just like you would register them manually.

A rule of thumb is to first install your application manually (copy/paste, execute register command lines etc.). Only then you will be able to successfully configure an installer which does it automatically.