Skip to content

Commit d91a8f0

Browse files
authored
Merge pull request #535 from GameTechDev/update-install-in-use-files
Changes to gracefully handle silent installs
2 parents b904a8e + 50447df commit d91a8f0

File tree

5 files changed

+51
-18
lines changed

5 files changed

+51
-18
lines changed

IntelPresentMon/PMInstaller/PresentMon.wxs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010

1111
<Package InstallerVersion="500" Compressed="yes" InstallScope="perMachine" Platform="x64"/>
1212

13+
<!-- Handle in-use files by scheduling for reboot (user will see FilesInUse dialog) -->
14+
<Property Id="MSIRESTARTMANAGERCONTROL" Value="DisableShutdown" />
15+
<Property Id="REBOOT" Value="ReallySuppress" />
16+
1317
<MajorUpgrade
1418
Schedule="afterInstallValidate"
1519
AllowDowngrades="no"
@@ -87,6 +91,17 @@
8791
<UIRef Id="WixUI_ErrorProgressText" />
8892

8993
<WixVariable Id="WixUILicenseRtf" Value="license.rtf" />
94+
95+
<!-- Custom action to set REINSTALLMODE for handling in-use files -->
96+
<CustomAction Id="SetReinstallMode"
97+
Property="REINSTALLMODE"
98+
Value="amus"
99+
Execute="immediate" />
100+
101+
<InstallExecuteSequence>
102+
<!-- Always set REINSTALLMODE to handle file replacement -->
103+
<Custom Action="SetReinstallMode" Before="CostInitialize">1</Custom>
104+
</InstallExecuteSequence>
90105
</Product>
91106

92107
<Fragment>
@@ -147,6 +162,10 @@
147162
Id="DesktopFolder"
148163
Name="Desktop">
149164
</Directory>
165+
<Directory
166+
Id="WindowsFolder">
167+
<Directory Id="SystemFolder" Name="System32" />
168+
</Directory>
150169
</Directory>
151170
</Fragment>
152171

IntelPresentMon/PMInstallerLib/Library.wxs

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
33
<Fragment>
44

@@ -9,11 +9,15 @@
99
<!-- PresentMonService.exe (key file + Windows service) -->
1010
<Component Id="pmon_shared_service_component"
1111
Guid="{45531AC0-CEB6-4DD0-B6B6-2BAD7F6AD01E}"
12-
Win64="yes">
12+
Win64="yes"
13+
NeverOverwrite="no"
14+
Permanent="no">
1315
<File Id="pmon_shared_service_exe"
1416
Name="$(var.PresentMonService.TargetFileName)"
1517
Source="$(var.PresentMonService.TargetPath)"
16-
KeyPath="yes" />
18+
KeyPath="yes"
19+
Checksum="yes"
20+
Vital="yes" />
1721

1822
<ServiceInstall Id="PmSharedServiceInstall"
1923
Name="PresentMonSharedService"
@@ -22,15 +26,12 @@
2226
Start="auto"
2327
Type="ownProcess"
2428
ErrorControl="normal"
25-
Vital="yes" />
26-
27-
<!-- Stop before replace, remove on uninstall, start after install -->
29+
Vital="no" />
30+
<!-- Only handle service removal on uninstall - let RestartManager handle in-use files -->
2831
<ServiceControl Id="SharedPresentMonServiceControl"
2932
Name="PresentMonSharedService"
30-
Start="install"
31-
Stop="both"
3233
Remove="uninstall"
33-
Wait="yes" />
34+
Wait="no" />
3435
<RemoveFolder Id ="PresentMonSharedServiceUninstall"
3536
Directory="service_folder"
3637
On="uninstall"/>
@@ -39,15 +40,32 @@
3940
<!-- PresentMonAPI2.dll -->
4041
<Component Id="present_mon_shared_dll_component"
4142
Guid="{BC2D2B30-9011-48E5-8592-ACC58CEFDF17}"
42-
Win64="yes">
43+
Win64="yes"
44+
NeverOverwrite="no"
45+
Permanent="no">
4346
<File Id="present_mon_shared_api_2_dll"
4447
Name="$(var.PresentMonAPI2.TargetFileName)"
4548
Source="$(var.PresentMonAPI2.TargetPath)"
46-
KeyPath="yes" />
49+
KeyPath="yes"
50+
Checksum="yes"
51+
Vital="yes" />
4752
</Component>
4853

4954
</DirectoryRef>
5055

56+
<!-- Smart service start - only if service is not already running -->
57+
<CustomAction Id="TryStartSharedService"
58+
Directory="SystemFolder"
59+
ExeCommand='cmd /c "sc query PresentMonSharedService | find "RUNNING" > nul || sc start PresentMonSharedService"'
60+
Execute="deferred"
61+
Impersonate="no"
62+
Return="ignore" />
63+
64+
<InstallExecuteSequence>
65+
<!-- After InstallServices has registered the service (and StartServices would have run) -->
66+
<Custom Action="TryStartSharedService" After="StartServices">1</Custom>
67+
</InstallExecuteSequence>
68+
5169
<!-- Group that consumers reference -->
5270
<ComponentGroup Id="service_files">
5371
<ComponentRef Id="pmon_shared_service_component" />

IntelPresentMon/PMInstallerLib/PMInstallerLib.wixproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,5 @@
3333
<RefTargetDir>INSTALLFOLDER</RefTargetDir>
3434
</ProjectReference>
3535
</ItemGroup>
36-
<!-- Add WiX extensions here only if you actually use them in Library.wxs -->
37-
<!-- <ItemGroup>
38-
<WixExtension Include="WixUtilExtension" />
39-
</ItemGroup> -->
4036
<Import Project="$(WixTargetsPath)" />
4137
</Project>

IntelPresentMon/ServiceMergeModule/ServiceMergeModule.wixproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@
1515
<ItemGroup>
1616
<!-- The module authoring file -->
1717
<Compile Include="ServiceMergeModule.wxs" />
18-
<!-- Link your existing wixlib so we get ComponentGroup Id='service_files' -->
19-
<!-- Add extensions only if your wixlib uses them -->
20-
<!-- <WixExtension Include="WixUtilExtension" /> -->
2118
</ItemGroup>
2219
<ItemGroup>
2320
<ProjectReference Include="..\PMInstallerLib\PMInstallerLib.wixproj">

IntelPresentMon/ServiceMergeModule/ServiceMergeModule.wxs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
<Directory Id="service_folder" Name="PresentMonSharedService" />
1616
</Directory>
1717
</Directory>
18+
<Directory Id="WindowsFolder">
19+
<Directory Id="SystemFolder" Name="System32" />
20+
</Directory>
1821
</Directory>
1922

2023
<!-- Pull in the payload from your wixlib; no <Feature> in a Module -->

0 commit comments

Comments
 (0)