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

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 […]

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.

There are a couple of options that you can use to prevent this dialog from appearing during unattended install of 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.

Option 1 - Disable and re-enable the Windows Update service: In this option, whatever script or process you are using to launch the .NET Framework 3.5 setup will temporarily disable the Windows Update service (wuauserv), run .NET Framework 3.5 setup, then re-enable the wuauserv service.

You need to issue the equivalent of the following set of commands to achieve this:

  1. sc stop wuauserv
  2. sc config wuauserv start= disabled
  3. Install the .NET Framework 3.5
  4. sc config wuauserv start= auto
  5. sc start wuauserv
  6. Reboot the system if the .NET Framework 3.5 setup returns exit code 3010

Option 2 - Use Windows Update Agent (WUA) APIs to pause the Windows Update service: In this option, 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.

Windows Vista, Reboot, OS, .NET, Framework, Tips and Tricks

Source:→ MSDN Blog