fixed: shellex isn't loaded on install, restart needed.

This commit is contained in:
Nick Bolton 2014-03-11 19:24:51 +00:00
parent f3e47f840a
commit 3f28be1933
3 changed files with 72 additions and 3 deletions

View File

@ -34,6 +34,7 @@
</Feature> </Feature>
<Icon Id="synergy.ico" SourceFile="$(var.ResPath)/synergy.ico"/> <Icon Id="synergy.ico" SourceFile="$(var.ResPath)/synergy.ico"/>
<Binary Id="Scripts" SourceFile="Scripts.vbs" />
<WixVariable Id="WixUILicenseRtf" Value="$(var.ResPath)\License.rtf" /> <WixVariable Id="WixUILicenseRtf" Value="$(var.ResPath)\License.rtf" />
<WixVariable Id="WixUIBannerBmp" Value="$(var.ResPath)\banner.bmp" /> <WixVariable Id="WixUIBannerBmp" Value="$(var.ResPath)\banner.bmp" />
@ -56,10 +57,45 @@
NOT LEGACY_UNINSTALL_EXISTS NOT LEGACY_UNINSTALL_EXISTS
</Condition> </Condition>
<CustomAction Id="StartGui" FileKey="GuiProgram" ExeCommand="" Return="asyncNoWait" /> <CustomAction Id="RestartExplorerPrompt" BinaryKey="Scripts" VBScriptCall="RestartExplorerPrompt" />
<CustomAction Id="RestartExplorer" BinaryKey="Scripts" VBScriptCall="RestartExplorer" Execute="deferred" Impersonate="yes" />
<CustomAction Id="StartGui" FileKey="GuiProgram" ExeCommand="" Return="asyncNoWait" Execute="deferred" Impersonate="yes" />
<!--
generally it is ill-advised to use custom actions and vbscript,
as this makes it really hard to guarentee clean msi usage.
however, msi insists on checking for files-in-use before it
stops our service (which will turn up a ton of applications
using the hook and shellex dlls). its actually much cleaner for
us to disable the restart manager (MSIRESTARTMANAGERCONTROL) and
forcefully restart explorer.exe ourselves. patches welcome!
-->
<InstallExecuteSequence> <InstallExecuteSequence>
<Custom Action="StartGui" After="InstallFinalize">NOT Installed</Custom>
<!--
ask the user if we can restart explorer, but only on install or
upgrade (known as "NOT Installed"), and only if not running in
passive/quiet mode.
-->
<Custom Action="RestartExplorerPrompt" Before="InstallFinalize">
NOT Installed AND (UILevel = 4 OR UILevel = 5)
</Custom>
<!--
if the user answered the restart explorer dialog, then this must
be an attented install, so it should be ok for us to restart
explorer, start the gui, and potentially reboot.
-->
<Custom Action="RestartExplorer" After="RestartExplorerPrompt">
RESTART_EXPLORER="yes"
</Custom>
<Custom Action="StartGui" After="RestartExplorer">
RESTART_EXPLORER="yes"
</Custom>
<ScheduleReboot After="RestartExplorer">
RESTART_EXPLORER="no"
</ScheduleReboot>
</InstallExecuteSequence> </InstallExecuteSequence>
</Product> </Product>

View File

@ -0,0 +1,32 @@
Function RestartExplorerPrompt
Dim message
message = "The Windows Explorer process needs to be restarted. " & _
"A reboot is required if you do not wish to do this. " & vbCr & vbCr & _
"Would you like setup to restart the Windows Explorer process?"
answer = MsgBox(message, vbSystemModal Or vbYesNo Or vbQuestion, "Restart Explorer")
If answer = vbYes Then
restart = "yes"
Else
restart = "no"
End If
Session.Property("RESTART_EXPLORER") = restart
End Function
Function RestartExplorer
Set wmi = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set processList = wmi.ExecQuery("Select * from Win32_Process Where Name = 'explorer.exe'")
For Each process in processList
process.Terminate(1)
Next
Set shell = CreateObject("Wscript.Shell")
shell.Run "explorer.exe"
End Function

View File

@ -12,6 +12,7 @@
<IntermediateOutputPath>..\..\..\build\wix\obj\$(Configuration)\</IntermediateOutputPath> <IntermediateOutputPath>..\..\..\build\wix\obj\$(Configuration)\</IntermediateOutputPath>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Content Include="Scripts.vbs" />
<WixExtension Include="WixFirewallExtension"> <WixExtension Include="WixFirewallExtension">
<HintPath>$(WixExtDir)\WixFirewallExtension.dll</HintPath> <HintPath>$(WixExtDir)\WixFirewallExtension.dll</HintPath>
<Name>WixFirewallExtension</Name> <Name>WixFirewallExtension</Name>