Fix it now
The installer tried to create a file and the file system refused. The path in the message is the diagnosis, and the system error code printed beside it says what went wrong: denied, in use, or not found. Nothing here indicates a bad package.
msiexec /i "C:\path\to\package.msi" /l*v %USERPROFILE%\Desktop\msi.log
icacls "C:\Program Files\Vendor"
icacls "C:\Program Files\Vendor" /inheritance:e
icacls "C:\Program Files\Vendor" /grant "SYSTEM:(OI)(CI)F" "Administrators:(OI)(CI)F" /T
- Read the full path from the message, or from the log if the dialog truncated it, and note the system error code beside it.
- If the file already exists, find what is holding it open: run
resmon, go to the CPU tab, and type the file name into the Associated Handles box. - Clear read-only and system attributes if something set them:
attrib -r -s "C:\Program Files\Vendor\*" /s /d. - Run the installer again from the elevated prompt.
Apply the permission commands to the specific product folder in your message, not to the whole of Program Files. A recursive change across the entire tree is slow and flattens permissions other products rely on.
If setup completes without offering to retry or ignore a file, you are done. If not, the next section works through who is doing the writing and why it is being refused.
Why it happens
In a per-machine installation the file copy is performed by the Windows Installer service running as SYSTEM, not by your logged-on account. That single fact explains most of the confusing cases. SYSTEM has broad rights on the local machine, but on the network it presents as the computer account, so a write that leaves the machine needs the computer account to have access, not you.
That is why folder redirection is such a reliable trigger. If Documents, AppData or the Desktop have been redirected to a file server and a package writes into one of those locations during a per-machine install, the write arrives at the share as the computer account. Unless the share grants that account rights, the write fails and the message names a UNC path or a redirected local path.
The numbers in this family are more precise than they look, and it is worth matching yours to the published wording rather than to the phrasing on your screen. 1310 is published as an error attempting to create the destination file, with a system error code attached. 1304 is published as an error writing to a file. 1303 and 1321 are the two privilege cases – insufficient privileges to access a directory, and insufficient privileges to modify an existing file. 1317 is a directory that could not be created, and 1320 is a path that is simply too long.
Many packages display their own wording for these numbers, because the strings the installer shows come from a table inside the package rather than from Windows. The number and the path are the parts that stay reliable, and the system error code inside a 1310 message is the single most useful value on the screen: 5 is access denied, 32 is a sharing violation, 3 is a missing path.
Inheritance was broken on the target folder
You have this one if icacls on the named folder shows fewer entries than its parent, or entries without the (I) inherited marker.
- Re-enable inheritance:
icacls "C:\Program Files\Vendor" /inheritance:e. - Grant the standard rights if they are missing:
icacls "C:\Program Files\Vendor" /grant "SYSTEM:(OI)(CI)F" "Administrators:(OI)(CI)F" /T. - If ownership is wrong, take it first with
takeown /f "C:\Program Files\Vendor" /r /d y, then reapply the grant.
A running process has the file open
You have this one if The path names a file that exists, the system error is 32, and the install works after a reboot or in Safe Mode.
- Open Resource Monitor with
resmon, select the CPU tab, and search Associated Handles for the file name. - Close that application, or stop the service that owns it with
sc.exe stop <servicename>. - If a shell extension or preview handler holds it, restarting Explorer is often enough.
- Reboot and run the installer before anything else starts if the file is held by the operating system itself.
The target is a redirected or network path
You have this one if The failing path is a UNC path, or a profile folder redirected to a server; local accounts install and domain accounts do not.
- Confirm redirection with
gpresult /h report.htmland read the Folder Redirection section. - If the package must write there during a per-machine install, grant the computer account write access on both the share and the NTFS permissions.
- Otherwise install to a local path using whatever target property the package exposes.
- For per-user components, deploy in the user’s own context so the write happens with the user’s token.
The path is too long or contains something unusable
You have this one if 1320 appears, or the path in the message is unusually deep, or a folder name was generated from a long product display name.
- Copy the package to a short path such as
C:\pkgand run it from there rather than from a deep Downloads subfolder. - Shorten the install target and retry.
- Check for trailing spaces or unusual characters in a folder name along the path.
Full reference
The published message for each number
| Number | Published message |
|---|---|
| 1303 | The Installer has insufficient privileges to access this directory: [2]. |
| 1304 | Error writing to File: [2] |
| 1310 | Error attempting to create the destination file: [3]. System error code: [2] |
| 1317 | An error occurred while attempting to create the directory: [2] |
| 1320 | The specified path is too long: [2] |
| 1321 | The Installer has insufficient privileges to modify this file: [2]. |
If the dialog on your screen says something different next to the same number – the familiar “Error writing to file … Verify that you have access to that directory” is the common one – that wording came out of the package, not out of Windows. Microsoft publishes the strings above. Diagnose from the number, the path and the system error code, all three of which are stable.
Reading the system error code
| System error | Meaning | Where that puts you |
|---|---|---|
| 5 | Access denied | Permissions or ownership on the folder in the message |
| 32 | The process cannot access the file because it is being used by another process | Find the handle with Resource Monitor |
| 3 | The path was not found | A missing parent folder, or a target on a drive that is not there |
| 112 | There is not enough space on the disk | Free space on the target volume, not on C: by habit |
| 2 | The system cannot find the file specified | A source file that is not where the package expects it |
Command reference
| Command | What it tells you or does |
|---|---|
icacls "<path>" |
Prints the current permissions, including whether they are inherited |
icacls "<path>" /inheritance:e |
Re-enables inheritance from the parent folder |
takeown /f "<path>" /r /d y |
Takes ownership of a folder tree |
attrib -r -s "<path>\*" /s /d |
Clears read-only and system attributes recursively |
resmon |
Opens Resource Monitor, where Associated Handles identifies the locking process |
Cases that look like permissions and are not
- Only .exe or .dll files fail. Real-time scanning is holding files as they are written; exclude the staging folder rather than turning protection off.
- The path is under Program Files but the volume is nearly full. Windows Installer stages before it commits, so it needs room for both copies.
- Every path fails on one machine and none on an identical build. Look at a hardening baseline or a security template before touching individual folders.
- The file exists with a zero byte size. A previous failed install left a stub; delete it and run setup again.
- The target is on removable or encrypted storage that is not unlocked at the point setup runs.
What clicking Ignore actually does
The retry dialog offers Ignore, and it does what it says: the transaction continues and the file that failed is simply absent. Setup then reports success. The application will fail later, at a point that has nothing obvious to do with an installation you performed weeks earlier, and the log that would have explained it is long gone. Fix the path and install properly, or cancel and come back to it.
Every code this article covers
| Code | What it points at | Source |
|---|---|---|
1310 |
The installer could not create the destination file; the message carries the path and a system error code | Microsoft Learn |
1303 |
The installer has insufficient privileges to access the named directory | Microsoft Learn |
1321 |
The installer has insufficient privileges to modify the named existing file | Microsoft Learn |
1304 |
An error occurred writing to the named file – this is the number Microsoft publishes the “error writing to file” wording under | Microsoft Learn |
1317 |
A directory the package needed could not be created | Microsoft Learn |
1320 |
The specified path is too long | Microsoft Learn |
Confirm the fix worked
- Rerun the installer and confirm it completes without prompting to retry or ignore any file.
- Open the install folder and confirm the file from the original message is present, with a sensible size and date.
- Run
icaclson the install folder and confirm SYSTEM and Administrators hold full control through inherited entries. - Start the application and use the feature that depends on the file that previously failed to copy.
- If the path was redirected, sign in as a second affected user and confirm the install works there too.
Questions people ask about this
Is there anything here I have to pay for?
No. Every cause is a permission, a lock or a path problem on hardware you already own, and every tool used to fix it ships with Windows. No licence purchase affects this error.
My dialog says “Error writing to file. Verify that you have access to that directory” next to 1310. Is this the right article?
Yes. That wording comes from the package’s own message table rather than from Windows; Microsoft publishes 1310 as an error attempting to create the destination file, with a system error code attached. Work from the number, the path and that system error code.
Should I just run the installer as the built-in Administrator?
It sometimes works, because that account is not subject to the filtered token, but it hides the fault rather than fixing it. If the ACL on the target folder is wrong, the application will hit the same wall the next time it updates itself.
Why does Safe Mode fix it?
Because far fewer processes are running, so nothing holds the target file open and most third-party filter drivers are not loaded. An install that succeeds in Safe Mode and fails normally is a lock or a security product, not permissions.
Can I ignore the error and carry on?
You can, and setup may report success, but the file that failed will be missing. Expect the application to break later in a way that is much harder to trace. Fix the path and reinstall.
