Skip to content

Est. 2011ยทMicrosoft Partner ID 7033487ยทDelivery under 3 minยทSupport 7 days a week

Your vault is empty.

License Error 1306

MSI 1306: The File Is in Use and Setup Cannot Replace It

10 min read Updated October 5, 2026 Installers, Runtimes & App Deployment

Fix it now

Windows Installer message 1306 is “the file ‘[2]’ is in use. If you can, please close the application that is using the file, then click Retry.” Something holds an open handle to the file setup is replacing. Get the file name out of a verbose log first, because without it there is nothing to close or exclude.

Run this from an elevated Command Prompt, then open the log

msiexec /i package.msi /l*v C:\temp\install.log
  1. Search the log for the error, then read back a few lines to find the file path setup was working on. That path is the whole diagnosis.
  2. Find what holds it: press Start, type resmon, open the CPU tab, expand Associated Handles and search for the file name.
  3. If a service belonging to the product you are upgrading holds it, stop that service with sc stop <servicename> before retrying.
  4. If a real-time scanner holds it, add a temporary exclusion for the target folder, run the installer, then remove the exclusion again.
  5. If neither works, reboot and run the installer before anything else starts. That clears file mappings nothing else can.

0x800704C8 is the stricter variant: ERROR_USER_MAPPED_FILE, ‘the requested operation cannot be performed on a file with a user-mapped section open.’ A loaded executable or library cannot be replaced at all while the mapping exists, whatever permissions you hold.

If the install completes, stop here. If it fails on a different file each time, the next section explains why and what to do about it.

Why it happens

When Windows opens a file, the opener states what access it needs and what it will permit others to do at the same time. An installer replacing a file needs an open that excludes other writers. If another process already holds the file in a way that does not permit that, the open fails and Windows Installer reports message 1306. The Win32 expression of the same fault is 0x80070020, ERROR_SHARING_VIOLATION – “the process cannot access the file because it is being used by another process.”

Real-time scanning creates a narrow but reliable window for this. As a file is created or closed, the scanner opens it to examine the contents. If the installer’s next operation on that file arrives during that window, the two collide. That is why the failure is intermittent, why it lands on a different file between attempts, and why it is more common on slower disks and busier machines – the window is the same length but there is more chance of something falling into it.

0x800704C8 is a different and harder case. ERROR_USER_MAPPED_FILE means the file has a memory-mapped section open, which is what happens when an executable or library is loaded by a running process. A mapped image cannot be replaced while the mapping exists. Rebooting works precisely because the mapping is gone before anything has a chance to recreate it, which is why “reboot and run it first” is not a superstition here.

Real-time scanning holds files as they are written

You have this one if The install fails on a different file each attempt, and succeeds occasionally on an idle machine.

  1. Add an exclusion for the installation target folder and the installer’s own temporary directory, in the security product’s management console.
  2. Run the install, confirm it completes, then remove the exclusion.
  3. If the product supports it, scope the exclusion to the process rather than the folder so you are not leaving a directory permanently unscanned.

Turning the scanner off entirely is a diagnostic step, not a fix. Confirm the cause, then narrow it to an exclusion.

A process from the product you are upgrading is still running

You have this one if The same file fails every time, and it belongs to the application being replaced.

  1. Stop the owning service first: sc query <servicename> to check its state, then sc stop <servicename>.
  2. Close tray components and helper processes as well. They keep libraries loaded after the main window closes.
  3. tasklist /m <name>.dll lists every process with that module loaded, which is faster than guessing.

The file is memory-mapped by a loaded module

You have this one if 0x800704C8 rather than 0x80070020, and no amount of permission work changes anything.

  1. Reboot and run the installer before anything else starts. This is the reliable answer for a mapped image.
  2. Identify what loads it with tasklist /m <name>.dll so you know whether it will simply reload.
  3. If it is a shell extension or a driver-adjacent component, expect it to be back within seconds of logon – the reboot-then-install ordering matters.

It is the source, not the target

You have this one if Message 1305 rather than 1306: ‘Error reading from File: [2]; System error code: [3]’.

  1. Read the system error code that message carries. It names the underlying failure precisely.
  2. Copy the installation source locally and run it from there rather than from a share or removable media.
  3. 1308, ‘Source file not found’, points the same way: the media the installer expects is not where it thinks it is.

Full reference

The messages either side of 1306

Message Microsoft’s published text
1304 Error writing to File: [2]
1305 Error reading from File: [2]; System error code: [3]
1306 The file ‘[2]’ is in use. If you can, please close the application that is using the file, then click Retry
1307 There is not enough disk space remaining to install this file: [2]
1308 Source file not found: [2]

1307 is mistaken for 1306 more often than any of the others, because both interrupt the file copy stage and both quote a file name. If the message mentions disk space, stop looking for a process holding a handle and go and free some space.

Reading the verbose log

msiexec /i package.msi /l*v C:\temp\install.log writes a verbose log with all information plus a verbose output. Open it and search for the error number rather than reading forwards; the lines immediately before the failure carry the file path and the action that was running. That path is what you exclude, what you stop, and what you look up in Resource Monitor – none of which you can do from the dialog alone.

Do the log first, not last. Rebooting fixes a large share of these, but if the reboot does not fix it you have destroyed the evidence and have to reproduce the failure to get it back.

Commands that answer the question

Command What it tells you
msiexec /i package.msi /l*v C:\temp\install.log The verbose log, including the file the installer was on when it failed
tasklist /m <name>.dll Every process with that module loaded
sc query <servicename> The current state of a service
sc qc <servicename> Its configuration, including the binary path – useful for confirming ownership
sc stop <servicename> Sends the stop control
resmon Resource Monitor. CPU tab, Associated Handles, search by file name

Exclusions that are worth having permanently

  • Scope them to a folder and, where the product allows, to a process. A blanket exclusion for an entire drive is not a fix, it is a hole.
  • Set them in the management console, not on the device. A per-device exclusion made during a rollout is gone the next time policy refreshes.
  • Include the installer’s temporary working directory, not only the destination. Much of the copying happens there.
  • Remove the temporary ones. An exclusion added to get one install through and then forgotten is exactly the kind of thing that turns up in an audit years later.
  • Where a vendor publishes its own recommended exclusion list for a product being installed, use that list rather than inventing one.

When it still fails after a reboot

  1. Check the log again for the new file name. A different file means you are watching the scanner window, not one stubborn process.
  2. Boot with third-party services disabled and try once. That separates the security product from everything else without uninstalling anything.
  3. Look for 1307 in the log. Disk space failures at the copy stage read very much like sharing violations.
  4. Confirm the source is readable end to end if 1305 or 1308 appear anywhere in the log.

When a licence is the actual fix

The install failure itself is free to fix – a log, an exclusion and a reboot. What costs money is doing that thirty times across an estate because the exclusions have to be set device by device and nobody can see which machine has which. That is the practical argument for a managed endpoint tier such as ESET PROTECT Entry: exclusions and real-time scanning settings are defined once in a console and applied to a group, and when an install fails on one machine you can see what policy that machine actually has rather than guessing. Judge any candidate on whether exclusions can be scoped to a path and a process, whether they are centrally applied, and whether the console shows you the effective policy on a device. If you manage a handful of machines and set exclusions by hand anyway, a licence upgrade buys you nothing here.

Every code this article covers

Code What it points at Source
1306 Windows Installer message: “The file ‘[2]’ is in use. If you can, please close the application that is using the file, then click Retry” Microsoft Learn
1305 Windows Installer message: ‘Error reading from File: [2]; System error code: [3]’ – a source-side read failure rather than a target-side write failure Microsoft Learn
0x80070020 Win32 error 32, ERROR_SHARING_VIOLATION: ‘the process cannot access the file because it is being used by another process’ Microsoft Learn
0x800704C8 Win32 error 1224, ERROR_USER_MAPPED_FILE: ‘the requested operation cannot be performed on a file with a user-mapped section open’ Microsoft Learn

Confirm the fix worked

  1. The verbose log for the successful run shows the file copy stage completing rather than retrying.
  2. The application starts and its service, if it has one, is running.
  3. Any temporary exclusion you added has been removed, and a scan of that folder completes.
  4. A second machine with the same security policy installs the same package cleanly.

Questions people ask about this

Why does it fail on a different file every time?

That is the signature of a real-time scanner rather than one stubborn process. The scanner opens each file briefly as it is written, and the collision lands wherever the timing happens to put it. A per-file fix will not help; an exclusion for the folder will.

Is rebooting really the fix, or am I just avoiding the problem?

For 0x800704C8 it is genuinely the fix. A file with a user-mapped section open cannot be replaced while the mapping exists, and a reboot is the only reliable way to clear a mapping created by something that reloads itself. Run the installer before anything else starts.

Can I take ownership or change permissions to force it through?

No, and it will not help. This is not a permissions failure – it is a sharing mode conflict. Changing ACLs on a file another process already holds open changes nothing about the conflict and leaves you with permissions you did not intend.

What is the difference between 1305 and 1306?

1306 is the target file being in use. 1305 is a read failure on the source, and it carries a system error code that names the real cause. If you see 1305 or 1308, look at where the installation source lives rather than at what is running on the machine.

Related error codes

Was this article helpful?

Your feedback helps us improve our documentation.

Related articles

Free Fix Runtime Error R6034: An Application Made an Invalid Attempt to Load the CRT Free Fix MSI 1335: The Cabinet File Required for This Installation Is Corrupt Free Fix MSI 2738 and 2739: Could Not Access VBScript or JScript Runtime in Setup Free Fix MSI 1639 and 1624: Invalid Command Line or Transform in Silent Deployments
โ† Back to Knowledge Base