I have an application that needs to upgrade itself, so it runs an MSI that installs the application while the application is still running. For years that has worked successfully, despite the .exe's, .dll's and other things being in use the installer works without a problem. However I am now installing the CEF browser component and this is causing me trouble.
This is an example from the installer log:
*** the file is scheduled for removal
MSI (s) (9C:7C) [11:44:06:372]: Executing op: FileRemove(,FileName=cef.pak,,ComponentId={AEDD9CDD-C5CB-4260-A5D5-A7C13011CC97})
MSI (s) (9C:7C) [11:44:06:374]: Verifying accessibility of file: cef.pak
MSI (s) (9C:7C) [11:44:06:374]: Verifying accessibility of file: cef.pak
MSI (s) (9C:7C) [11:44:06:374]: Using source file security for destination.
MSI (s) (9C:7C) [11:44:06:375]: Note: 1: 2318 2: C:\Config.Msi\144c57.rbf
MSI (s) (9C:7C) [11:44:06:390]: Note: 1: 2329 2: 32 3: C:\xxxx\cef.pak
MSI (s) (9C:7C) [11:44:06:390]: Verifying accessibility of file: cef.pak
MSI (s) (9C:7C) [11:44:06:393]: Executing op: FileRemove(,FileName=cef_100_percent.pak,,ComponentId={AEDD9CDD-C5CB-4260-A5D5-A7C13011CC97})
Info 1903. Scheduling reboot operation: Deleting file C:\xxxx\cef.pak. Must reboot to complete operation.
*** The file is not overwritten and it sees the files as the same
MSI (s) (9C:30) [11:44:09:050]: Executing op: FileCopy(SourceName=cef.pak,SourceCabKey=cef.pak,DestName=cef.pak,Attributes=512,FileSize=1961473,PerTick=65536,,VerifyMedia=1,,,,,CheckCRC=0,,,InstallMode=58982400,HashOptions=0,HashPart1=885556701,HashPart2=2067920947,HashPart3=-336625845,HashPart4=-1380829775,,)
MSI (s) (9C:30) [11:44:09:056]: File: C:\xxxxcef.pak; Won't Overwrite; Won't patch; Existing file is unversioned and unmodified - hash matches source file
So the installer tries to remove the file, knows it is in use and schedules a remove after the reboot. But then it sees if it should install the file, sees it is already there (it hasn't been removed yet) and decides to not do anything. So after the reboot the file is gone and the application fails.
I tried setting the installer to always replace the file with:
<Property Id='REINSTALLMODE' Value='amus'/>
On Windows 7 this produces the desired behaviour, the file is seen as being in use, the new one is copied to a temporary location and a rename scheduled for after a reboot and delete.
Line 1525: MSI (s) (CC:64) [12:19:41:201]: The file represented by File table key 'cef.pak' has no eligible binary patches
Line 2618: MSI (s) (CC:64) [12:19:41:775]: Executing op: FileRemove(,FileName=cef.pak,,ComponentId={AEDD9CDD-C5CB-4260-A5D5-A7C13011CC97})
Line 2619: MSI (s) (CC:64) [12:19:41:776]: Verifying accessibility of file: cef.pak
Line 2620: MSI (s) (CC:64) [12:19:41:776]: Verifying accessibility of file: cef.pak
Line 2622: MSI (s) (CC:64) [12:19:41:779]: Note: 1: 2329 2: 32 3: C:\xxx\cef.pak
Line 2623: MSI (s) (CC:64) [12:19:41:779]: Verifying accessibility of file: cef.pak
Line 2625: Info 1903. Scheduling reboot operation: Deleting file C:\xxx\cef.pak. Must reboot to complete operation.
Line 3382: MSI (s) (CC:68) [12:19:42:632]: The file represented by File table key 'cef.pak' has no eligible binary patches
Line 3801: MSI (s) (CC:68) [12:19:42:933]: Executing op: FileCopy(SourceName=cef.pak,SourceCabKey=cef.pak,DestName=cef.pak,Attributes=512,FileSize=1961473,PerTick=65536,,VerifyMedia=1,,,,,CheckCRC=0,,,InstallMode=62914560,HashOptions=0,HashPart1=885556701,HashPart2=2067920947,HashPart3=-336625845,HashPart4=-1380829775,,)
Line 3801: MSI (s) (CC:68) [12:19:42:933]: Executing op: FileCopy(SourceName=cef.pak,SourceCabKey=cef.pak,DestName=cef.pak,Attributes=512,FileSize=1961473,PerTick=65536,,VerifyMedia=1,,,,,CheckCRC=0,,,InstallMode=62914560,HashOptions=0,HashPart1=885556701,HashPart2=2067920947,HashPart3=-336625845,HashPart4=-1380829775,,)
Line 3801: MSI (s) (CC:68) [12:19:42:933]: Executing op: FileCopy(SourceName=cef.pak,SourceCabKey=cef.pak,DestName=cef.pak,Attributes=512,FileSize=1961473,PerTick=65536,,VerifyMedia=1,,,,,CheckCRC=0,,,InstallMode=62914560,HashOptions=0,HashPart1=885556701,HashPart2=2067920947,HashPart3=-336625845,HashPart4=-1380829775,,)
Line 3802: MSI (s) (CC:68) [12:19:42:939]: File: C:\xxx\cef.pak; Overwrite; Won't patch; REINSTALLMODE specifies all files to be overwritten
Line 3803: MSI (s) (CC:68) [12:19:42:939]: Source for file 'cef.pak' is compressed
Line 3805: MSI (s) (CC:68) [12:19:43:713]: Verifying accessibility of file: cef.pak
Line 3806: MSI (s) (CC:68) [12:19:43:713]: Verifying accessibility of file: cef.pak
Line 3808: MSI (s) (CC:68) [12:19:43:717]: Note: 1: 2329 2: 32 3: C:\xxx\cef.pak
Line 3809: MSI (s) (CC:68) [12:19:43:717]: Verifying accessibility of file: cef.pak
Line 3810: Info 1603. The file C:\xxx\cef.pak is being held in use. Close that application and retry.
Line 3811: Info 1903. Scheduling reboot operation: Deleting file C:\xxx\cef.pak. Must reboot to complete operation.
Line 3812: Info 1902. Scheduling reboot operation: Renaming file C:\xxx\TBMBFB2.tmp to C:\xxx\cef.pak. Must reboot to complete operation.
In Windows 10 however this does not occur, it tries to immediately replace the file without using the temporary file and it therefore fails.
cef.pak
Line 1895: MSI (s) (88:8C) [12:07:12:133]: The file represented by File table key 'cef.pak' has no eligible binary patches
Line 3011: MSI (s) (88:8C) [12:07:13:761]: Executing op: FileRemove(,FileName=cef.pak,,ComponentId={AEDD9CDD-C5CB-4260-A5D5-A7C13011CC97})
Line 3012: MSI (s) (88:8C) [12:07:13:763]: Verifying accessibility of file: cef.pak
Line 3013: MSI (s) (88:8C) [12:07:13:764]: Verifying accessibility of file: cef.pak
Line 3016: MSI (s) (88:8C) [12:07:13:782]: Note: 1: 2329 2: 32 3: c:\xxx\cef.pak
Line 3017: MSI (s) (88:8C) [12:07:13:782]: Verifying accessibility of file: cef.pak
Line 3019: Info 1903. Scheduling reboot operation: Deleting file c:\xxx\cef.pak. Must reboot to complete operation.
Line 3747: MSI (s) (88:8C) [12:07:16:042]: The file represented by File table key 'cef.pak' has no eligible binary patches
Line 4322: MSI (s) (88:8C) [12:07:16:577]: Executing op: FileCopy(SourceName=cef.pak,SourceCabKey=cef.pak,DestName=cef.pak,Attributes=512,FileSize=1961473,PerTick=65536,,VerifyMedia=1,,,,,CheckCRC=0,,,InstallMode=62914560,HashOptions=0,HashPart1=885556701,HashPart2=2067920947,HashPart3=-336625845,HashPart4=-1380829775,,)
Line 4322: MSI (s) (88:8C) [12:07:16:577]: Executing op: FileCopy(SourceName=cef.pak,SourceCabKey=cef.pak,DestName=cef.pak,Attributes=512,FileSize=1961473,PerTick=65536,,VerifyMedia=1,,,,,CheckCRC=0,,,InstallMode=62914560,HashOptions=0,HashPart1=885556701,HashPart2=2067920947,HashPart3=-336625845,HashPart4=-1380829775,,)
Line 4322: MSI (s) (88:8C) [12:07:16:577]: Executing op: FileCopy(SourceName=cef.pak,SourceCabKey=cef.pak,DestName=cef.pak,Attributes=512,FileSize=1961473,PerTick=65536,,VerifyMedia=1,,,,,CheckCRC=0,,,InstallMode=62914560,HashOptions=0,HashPart1=885556701,HashPart2=2067920947,HashPart3=-336625845,HashPart4=-1380829775,,)
Line 4323: MSI (s) (88:8C) [12:07:16:584]: File: c:\xxx\cef.pak; Overwrite; Won't patch; REINSTALLMODE specifies all files to be overwritten
Line 4324: MSI (s) (88:8C) [12:07:16:584]: Source for file 'cef.pak' is compressed
Line 4325: MSI (s) (88:8C) [12:07:16:585]: Re-applying security from existing file.
Line 4326: MSI (s) (88:8C) [12:07:21:645]: Verifying accessibility of file: cef.pak
Line 4327: MSI (s) (88:8C) [12:07:21:647]: Using source file security for destination.
Line 4328: MSI (s) (88:8C) [12:07:21:647]: Note: 1: 2318 2: C:\Config.Msi\a5880.rbf
Line 4329: MSI (s) (88:8C) [12:07:21:651]: Note: 1: 1310 2: 0 3: c:\xxx\cef.pak
Line 4330: Info 1603. The file c:\xxx\cef.pak is being held in use. Close that application and retry.
Line 4331: MSI (s) (88:8C) [12:07:21:652]: Product: XXX-- Error 1310. Error writing to file: c:\xxx\cef.pak. System error 0. Verify that you have access to that directory.
Line 4332:
Line 4333: Error 1310. Error writing to file: c:\xxx\cef.pak. System error 0. Verify that you have access to that directory.
Line 4334: MSI (s) (88:8C) [12:07:21:683]: Note: 1: 2265 2: 3: -2147287035
Line 4335: MSI (s) (88:8C) [12:07:21:684]: User policy value 'DisableRollback' is 0
Line 4336: MSI (s) (88:8C) [12:07:21:684]: Machine policy value 'DisableRollback' is 0
Line 4337: Action ended 12:07:21: InstallFinalize. Return value 3.
Line 4347: MSI (s) (88:8C) [12:07:21:713]: Executing op: FileCopy(SourceName=C:\Config.Msi\a5880.rbf,,DestName=c:\xxx\cef.pak,Attributes=32,FileSize=0,PerTick=0,,VerifyMedia=0,ElevateFlags=3,,,,,,,InstallMode=4194304,,,,,,,)
Line 4348: MSI (s) (88:8C) [12:07:21:713]: File: c:\xxx\cef.pak; Overwrite; Won't patch; REINSTALLMODE specifies all files to be overwritten
Line 4349: MSI (s) (88:8C) [12:07:21:715]: Re-applying security from existing file.
Line 4350: MSI (s) (88:8C) [12:07:21:718]: Note: 1: 2318 2:
Line 4351: MSI (s) (88:8C) [12:07:21:720]: Verifying accessibility of file: cef.pak
Line 4352: MSI (s) (88:8C) [12:07:21:722]: Using source file security for destination.
Line 4353: MSI (s) (88:8C) [12:07:21:722]: Note: 1: 2318 2: C:\Config.Msi\a5881.rbf
Line 4354: MSI (s) (88:8C) [12:07:21:735]: File will have security applied from OpCode.
Line 4355: MSI (s) (88:8C) [12:07:21:737]: Note: 1: 1310 2: 32 3: c:\xxx\cef.pak
Line 4356: Info 1603. The file c:\xxx\cef.pak is being held in use. Close that application and retry.
Line 4357: MSI (s) (88:8C) [12:07:21:737]: Error in rollback skipped. Return: 3
Line 4358: Info 1310. Error writing to file: c:\xxx\cef.pak. System error 32. Verify that you have access to that directory.
Is there a way to get that behaviour for other types of files (e.g .pak files)?