Why Can't I Delete autorun.inf? ("Access Is Denied" Explained)
If Windows won't let you delete an autorun.inf file — with errors like "Access is denied," "There has been a sharing violation," or "The source or destination file may be in use" — it's usually caused by one of three things:
- The file has the hidden, system, or read-only attribute set, which blocks normal deletion
- Another process (often Explorer itself, or an antivirus scan) has the file locked/open
- The autorun.inf was planted by malware on a USB drive or hard disk to auto-launch a malicious program — this is one of the most common ways autorun.inf ends up somewhere you didn't put it
Because that third cause is common, it's worth treating an unexpected autorun.inf as a possible infection, not just a stuck file — see the security note near the end before you dismiss it as a simple glitch.
Fix 1: Remove the File Attributes, Then Delete
Most of the time, this alone solves it. Open Command Prompt as Administrator and run:
attrib -s -h -r X:\autorun.inf
del X:\autorun.inf
Replace X: with the actual drive letter (for example, your USB drive or a partition). The -s -h -r flags strip the system, hidden, and read-only attributes so the file behaves like a normal one.
Fix 2: Delete It From Safe Mode
If Fix 1 fails because another process is holding the file open, boot into Safe Mode and try again:
- Restart your PC and enter Safe Mode (Settings » Recovery » Advanced Startup, or hold Shift while clicking Restart)
- Open Command Prompt as Administrator
- Run the
attribanddelcommands from Fix 1
Safe Mode loads a minimal set of drivers and startup programs, so whatever was locking the file in normal Windows usually isn't running here.
Fix 3: Take Ownership if Permissions Are the Issue
If you still get "Access is denied" after removing attributes, you may not own the file. Run these from an elevated Command Prompt:
takeown /f X:\autorun.inf
icacls X:\autorun.inf /grant administrators:F
del X:\autorun.inf
This forces ownership to your account and grants full control before deleting.
Fix 4: Format the Drive (Last Resort)
If the drive is a USB stick or external disk and nothing above works, backing up your data and formatting the drive removes the file along with anything else hiding on it — useful if you suspect malware rather than a simple permissions issue.
Security Note: Unexpected autorun.inf Files Can Signal Malware
Legitimate software rarely needs autorun.inf today — most modern Windows versions have AutoRun disabled by default for removable drives specifically because it was widely abused by malware to self-launch when a USB drive was plugged in. If an autorun.inf file appears on a drive without you putting it there, run a full antivirus/anti-malware scan on that drive before reusing it, and avoid opening the file to "see what it does."
FAQ
Is deleting autorun.inf safe?
Yes, in almost all cases. Windows doesn't need autorun.inf to function normally, and AutoRun from removable media is disabled by default on modern Windows.
Why does autorun.inf keep coming back after I delete it?
This usually means malware on the drive is recreating the file. Run a full malware scan on the drive, and consider formatting it if the file keeps reappearing.
Do I need third-party software to delete a locked file?
Not usually. The attrib, Safe Mode, and takeown/icacls methods above resolve the vast majority of "access is denied" deletion issues using tools already built into Windows.
Thank you for your message.