The autorun.inf file is a file with setup or disk information that you will most commonly find in removable disk drives. It gives Windows’ AutoPlay and AutoRun functions the ability to work with the removable drive, and in order for it to work, it must be located in the root folder of said removable drive. Note that you will not be able to see the autorun.inf file unless you have checked the “Show hidden files and folders” in the folder’s attributes.
In case you have a message that says “Access denied” whenever you try to delete, or in any way modify the file, there are two things that may have occurred. One of them is that an antivirus program has placed protection on the file to prevent a virus from infecting it and replacing the commands with its own, and the other one is that a virus has indeed infected the file, and it doesn’t allow you to do anything with it.
Whichever the case, there are solutions that allow you to remove the corrupted autorun.inf file, and you don’t have to worry since the removable drive will create a new one the next time you plug it in. The first method works if an antivirus has messed with the file, but if that doesn’t work, go on to the other methods that show how to delete the file even if a virus is denying you access to it.
Method 1: Copy your data and format the drive
If an antivirus has protected the file, the procedure to get rid of it is fairly easy. Open your drive, and select all data that you have on it, and don’t want to lose. Copy them to another location on your desktop, as they will be permanently deleted from the drive. Once they’re done copying (time needed will vary based on how much data you have and what speeds the drive works with), open My Computer or This PC, depending on which version of Windows you’re using. Locate the drive in question, and right-click on it. You will find in the dropdown menu a Format option, click it. In the window that opens, click the Start button, and wait for it to finish. Please make sure that it is the correct drive, and that you have copied all necessary data to another place on your desktop, as this program will delete everything on the drive you run it on. Once it’s done, you can copy your files to the drive again and continue using it as usual. If this fails to delete the file, it is most likely infected by a virus, so read on the following methods to solve the problem.
Method 2: Take ownership of the file and delete it afterwards
This method will require you to use an elevated command prompt, which can be a fairly powerful tool in situations like this. To open it, press the Windows button, or click on the Start button on your taskbar, and type cmd in the search box. Right-click the cmd app that appears in the results, and select Run as administrator from the dropdown menu. Once you’re inside, you will need to type the following command:
takeown /f F:\autorun.inf
Make sure not to make a mistake while typing, and if F: isn’t the drive of the letter you want to take care of, replace the letter with the appropriate one. You can see the letter in My Computer/This PC. Once you have ownership of the autorun.inf file, you can open your removable drive and delete it.
Method 3: Boot Windows into Safe Mode and delete the file
Booting Windows into Safe Mode will grant you the ability to do more advanced things than a regular boot, and it also blocks a number of services that might be the cause of your issues. Booting into Safe Mode is pretty easy.
For Windows 7/Vista
What you need to do first is turn off, or restart your computer. When you turn it on, or it turns on after the restart, press F8 a couple of times before Windows starts booting. Use the arrows on your keyboard to highlight Safe Mode and press Enter. Once you’re inside Windows, you can navigate to your removable thumb drive and delete the autorun.inf file.
For Windows 8/10: see steps (here)
Method 4: Delete the file directly through a Command Prompt and scan your computer
With this method you don’t need an Elevated Command Prompt – a regular one will do fine. You can open it by simultaneously pressing Windows and R on your keyboard, typing cmd in the search box and pressing Enter. Once inside, enter the following commands, and press Enter after each one:
cd F: or cd “whatever the drive path is”
attrib -r -h -s autorun.inf
Make sure not to mistake the spelling, including the spaces in the attrib command. After you’re done, restart the system and the problem will be fixed. However, the cause of the problem will most likely still be in your computer, so make sure to run a complete system scan with an antivirus program, to clean your system from any threats that may be inside.
Method 5: Use Diskpart to completely wipe the drive
NOTE: BE CAREFUL WITH THIS METHOD – DO IT ONLY IF YOU CAN UNDERSTAND THE METHOD. YOU MAY MISTAKENLY CORRUPT YOUR C: OR ROOT DRIVE IF YOU PERFORM IT INCORRECTLY. IN ANY CASE, MAKE SURE YOU HAVE A BACK UP OF ALL YOUR DATA.
This is another method that deletes everything from your drive, so make sure to copy your data beforehand. You can use either the clean or clean all commands – the second one is more thorough but takes more time, and you wouldn’t want to use it often as it decreases the life of the drive. The first step is to open an Elevated Command Prompt. You can see how to do so in Method 2 of this guide. When inside, type diskpart and press Enter.
At this point, you need to know the correct number of the drive you’re working with. This can be easily done by pressing Windows and R simultaneously, and typing compmgmt.msc, then pressing Enter (Click Yes if you get a UAC prompt). Select Disk Management in the left pane, and note the number of the disk you want to clean.
Back to diskpart, type list disk and press Enter. This gives a list of all disks connected to the computer, and you will need to select the one you need according to the number. For example, if it is Disk 1, you do this by typing select disk 1 and pressing Enter. In the list, see if the status of said disk is Online or Offline. If it is Offline, use the online disk command to bring it online. With the disk now selected, type clean or clean all, depending on which command you want to go with. When you’re done, type exit and press Enter, and close the Elevated Command Prompt afterwards.
Since the disk will now be shown as unallocated space, you will need to create a new partition. Do this by right-clicking the drive in question on the previously opened Disk Management window. Click New Simple Volume from the menu and follow the wizard to create a new partition. After that is done, your drive will be usable once again.
The Access denied message when working with autorun.inf can annoy a lot of users, however the fixes for it are easy, and by using the methods mentioned above, you will get rid of it in no time.