Recently, a friend of mine asked me a question about an installer that his team was working on. They have an MSI that is launched by a lightweight bootstrapper that is named something like ProductSetup.exe. When running this installer on Windows Vista, they noticed that Windows was automatically prompting for permission to elevate when the EXE was first launched.
After asking around a little bit about this scenario, I received a pointer to a really good white paper that has been published for public download - Windows Vista Application Development Requirements for User Account Control Compatibility.
This white paper includes details many aspects of designing and building applications that will work well with User Account Control (UAC) on Windows Vista.
At a high level, it describes the following steps to use when designing applications for Windows Vista:
- Test Your Application for Application Compatibility
- Classify Your Application as a Standard User, Administrator, or Mixed User Application
- Redesign Your Application's Functionality for UAC Compatibility
- Redesign Your Application's User Interface for UAC Compatibility
- Redesign Your Application's Installer
- Create and Embed an Application Manifest with Your Application
- Test Your Application
- Authenticode Sign Your Application
- Participate in the Windows Vista Logo Program
In addition, it describes some interesting setup-specific considerations. Windows Vista includes some logic to automatically prompt for elevations for processes that it believes are likely to be installer processes. For example, it will check for strings like setup, install, update and others in the name and file properties of a file.
In some cases, this automatic prompting can be annoying and undesirable. Fortunately, step 6 of the list above describes how you can override this behavior for your application - by creating and embedding an application manifest that specifies the requested execution level. In the case of an installer process that you do not want to prompt for elevation, you can specify the asInvoker execution level to prevent Windows Vista from automatically prompting because the word setup appears in the name of your application (as was the case with my friend's scenario).
In other cases I have seen, an application may want to request elevation when it is first launched to avoid possible file or registry permission problems later on. In those cases, you can mark your application with the highestAvailable or requireAdministrator execution level, and Windows Vista will prompt the user for elevation when launching the application.
If you are developing an application and/or an installer for Windows Vista, or have an existing application and/or installer that you plan to support on Windows Vista, I highly encourage reading the UAC white paper linked above and understanding the new scenarios that are introduced with UAC in Windows Vista.