How to avoid OS reboot prompt when installing the .NET Framework 3.5 on Windows Vista

Description of the issue

When installing the .NET Framework 3.5 or Visual Studio 2008 on Windows Vista RTM, some people have noticed that a Windows Update dialog box pops up to indicate that the system must be restarted in order to complete installation of OS updates.  The dialog box looks something like the following:

What is happening behind the scenes

Windows Vista includes the .NET Framework 2.0 and 3.0 as OS components.  The .NET Framework 3.5 includes Windows Vista OS hotfix packages for the .NET Framework 2.0 SP1 and 3.0 SP1, and both of these hotfixes require reboots in order to complete installation.  The .NET Framework 3.5 setup wrapper contains logic to handle these reboot requests and notify the user, but the Windows Update service in Windows Vista also runs in the background and listens for this type of reboot request and pops up dialog boxes like this to notify the user that a reboot is needed as the result of installing an OS update.

Unfortunately, if this dialog appears during the .NET Framework 3.5 setup or during installation of a product that installs the .NET Framework 3.5 as a prerequisite (such as Visual Studio 2008), and the user chooses to restart using the Restart Now button on this dialog, it can cause the system to reboot even if the .NET Framework 3.5 or Visual Studio 2008 setup is still running.  This can leave the system in an unknown state if these setups are installing something at the time of the reboot.

How to work around this issue

The Visual Studio 2008 readme will include an item suggesting that the user dismiss or ignore this Windows Update dialog if it is seen during .NET Framework 3.5 or Visual Studio 2008 setup.  However, the readme is not always easily found by end users, and this issue can potentially happen for any application that includes the .NET Framework 3.5 setup as a prerequisite on Windows Vista or during unattended deployment of the .NET Framework 3.5.

You can programatically prevent this dialog from appearing when deploying the .NET Framework 3.5.  This logic can be included in the script used for unattended deployment or within a setup process that includes the .NET Framework 3.5 as a prerequisite.

Use Windows Update Agent (WUA) APIs to pause the Windows Update service

To implement this solution, whatever script or process you are using to launch the .NET Framework 3.5 setup will use the Pause and Resume APIs on the IAutomaticUpdates interface in the Windows Update Agent (WUA) API set to temporarily pause and resume Windows Update functionality on the system.

You can use steps like the following to accomplish this:

  1. Call the Pause API to pause the Windows Update service
  2. Install the .NET Framework 3.5
  3. Reboot the system if the .NET Framework 3.5 setup returns exit code 3010
  4. Call the Resume API to resume the Windows Update service if the .NET Framework 3.5 setup does not return 3010

If you call Pause without calling Resume, the operation will eventually time out (the default time out value is 8 hours).  Rebooting the system will also cause the Windows Update service to resume without needing to call the Resume method.

<update date="12/13/2007"> Removing option suggesting that users disable the wuauserv service to workaround this issue. Doing this can cause failures during .NET Framework 2.0 SP1 or 3.0 SP1 installation on Windows Vista and should not be used. The valid workarounds are to ignore the reboot prompt or use the WUA Pause and Resume APIs </update>