PDA

View Full Version : How to Delete a System File in Windows Vista


laurentio
1st October 2008, 07:25 PM
Warning: Do not delete system files. Bad things will probably ensue.
If you need to delete or overwrite a system file in Windows Vista, you'll quickly notice that you cannot delete system files, even as administrator. This is because Windows Vista's system files are owned by the TrustedInstaller service by default, and Windows File Protection will keep them from being overwritten.
Thankfully, there's a way that you can get around this. You need to take ownership of the files, and then assign yourself rights to delete or modify the file. For this, we'll use the command line.
Open an administrator command prompt by typing cmd into the start menu search box, and hit the Ctrl+Shift+Enter key combination.
http://www.howtogeek.com/wp-content/uploads/2007/01/WindowsLiveWriter/RunaCommandasAdministratorfromtheWindow_F7DC/image%7B0%7D1.png
To take ownership of the file, you'll need to use the takeown command. Here's an example:
takeown /f C:\Windows\System32\en-US\winload.exe.mui
That will give you ownership of the file, but you still have no rights to delete it. Now you can run the cacls command to give yourself full control rights to the file:
cacls C:\Windows\System32\en-US\winload.exe.mui /me
Note that my username is "me", so you will substitute your username there.
At this point, you should be able to delete the file. If you still can't do so, you may need to reboot into Safe Mode and try it again. For the filename in the example, I was able to overwrite it without safe mode, but your mileage may vary.

Unregistered
1st October 2008, 07:31 PM
Good solution just that I have found an easier one:

Since i wanted to delete many system files from a previous Vista install on a secondary partition that i was cleaning up. i didn't want to reformat, so i tried delete and ran into this brick wall.

The solution that i find much easier for multiple files is the following:
(assuming you CAN use admin privs)
1)via folder properties go to your security tab.
2) in the bottom half you have the permissions listed for users, click the Advanced button
3) now go to the Owner tab, click Edit button (you will be asked for permision if UAC is at default)
4) change owner to your account and be sure to check the 'Replace owner on subcontainers and objects' and click Apply button. this results in all files including system files being switched to your account as owner!
5)now in the 'Advanced Security Settings for (your folder)' you need to edit the permissions: select your account (the one you just used to take ownership) and click Edit button.
6) you now see the Permissions tab and you need to again select your user account. (ensure that the permission is Full Control) check the lower 'Replace all existing inheritable permissions…' box and click Apply.

You are done! now you can close all the property stuff and just delete your folder. it may still ask for permission, but you now have the needed permissions to delete all contents of the folder.

Hope this solves the problem for anyone that needs to take care of multiple files, obviously it will work for a single file as well.

daydreaming
1st October 2008, 07:52 PM
For deleting folders in Vista (I did the whole of Program Files):

M:\>icacls "m:\program files" /grant martin: (D,WDAC) /t

martin is my user name. This grants delete and write rights to all folders, files and sub-folders in Program Files. No need to bother with takeowner as this seems to replace both it and cacls.

Thanks a LOT for the original tip L. Very helpful as I had a lot of wasted space on an old system drive which I have started using as a slave.

Steven Ringwald
1st October 2008, 07:55 PM
Just as an update to this, you can use the wonderful freeware program called "Unlocker", located here.
http://ccollomb.free.fr/unlocker/
Just right click the file in question, click the "Unlocker" option in the context menu, then highlight any programs using the file and click Unlock or Unlock All at the bottom of the window, you should then be able to delete the file.

I used this program a lot with WinXP and an so happy to have just learned it was Vista compatible as well.

You might need to go ahead and do the Take Ownership step above, I have the registry tweaks added that give me an option in the context menu for this and did that first.

laurentio
28th October 2008, 01:29 AM
Agree with Steven, unlocker is just great for this job.