Restart Manager functionality in WiX 3.5

Restart Manager functionality in WiX 3.5

  • Comments 3

WiX 3.5 provides features to integrate with Visual Studio 2005, 2008, and 2010. But like many add-ins, since new files are being added they certainly can’t be in use by devenv.exe. So when we call devenv.exe /setup as part of our install, the changes may not show up in running instances of Visual Studio.

To provide a better experience – and because this seems to be a fairly common request – I’ve added a custom action in WiX 3.5’s WixUtilExtension to use the Restart Manager in Vista and newer. The Restart Manager is capable of shutting down applications – similar to the normal files-in-use functionality in Windows Installer – but is also capable of restarting some of those applications. Visual Studio is not, unfortunately, one of those programs. But because Restart Manager provides APIs to add resources like file paths to devenv.exe, we can tell Windows Installer to detect and prompt that Visual Studio needs to be closed. Contrast this with detecting that Visual Studio is running and raising an error dialog. After you close Visual Studio, then you have to restart setup.

To use this functionality yourself – even if you target Windows XP, for example – you can author the RestartResource element similar to the example below.

<PropertyRef Id="VS2010DEVENV" />
<
DirectoryRef Id="BinDir"
>
    <
Component Id="VisualStudioPackage2010" Guid="C8D37529-F79E-46B4-89FD-EA7BC6654770" Win64="no"
>
        <
File Source="votive2010.dll" KeyPath="yes" Checksum="yes" Vital="yes"
/>
        <
util:RestartResource Path="[VS2010DEVENV]"
/>
    </
Component
>
</
DirectoryRef
>

Now when you install WiX 3.5 when Visual Studio is running, you should see the following message asking you to shut it down automatically or reboot after installation is complete. Because you are installing new files it will not actually prompt to reboot but you will not be able to use WiX successfully until you restart Visual Studio or start a new instance.

image

Leave a Comment
  • Please add 7 and 8 and type the answer here:
  • Post
  • I have an installer which requires WIndows Explorer to restart. Currently we force the user to restart, but I would like to a bit more gentle - at least for the users running Vista and Win7. Can I use this feature to ensure that Explorer gets restarted and what happens with WinXP users? Do I have to have a install sequence which is different for Vista and newer compared to WinXP? An example on how to handle Windows Explorer would be appreciated.

    Regards,

    Trond Andersen <trond.andersen at gmail.com>

  • Restart Manager is not available on XP, so the CA will do nothing. The install sequence would be different, but I'm not sure why that wouldn't be expected. Restart Manager was added in Vista to help reduce reboots.

    To register Windows Explorer, author an AppSearch/FileSearch that finds [WindowsFolder]explorer.exe. Alternatively you can just put that in the @Path attribute, but it's best to verify and find with AppSearch (for correctness).

  • Thanks a lot for your post ! I spent a lot of time time trying to use util:CloseApplication custom actions to get to a similar result, but the result wasn't clean (as you described). This is much, much cleaner !

Page 1 of 1 (3 items)