The proper way to do this is to include a manifest with your installer that requests elevation. Specifically, set the requestedExecutionLevel
to requireAdministrator
(rather than the default, asInvoker
):
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
This way, whenever a user running without elevated privileges launches the installer, Windows knows that the installer requires administrative privileges and automatically asks the user for valid credentials.
If the user can provide them, the installer is launched with administrative privileges, leaving other applications unaffected.
If the user cannot, the installer will fail to launch (which is fine, since it will fail anyway).
You can find more information on using manifests with UAC here from Microsoft.