Not able to delete file without permission from Nonexistant user/directory

6,944

If the issue is ownership, right-click on the file in Explorer, select Properties. On the Security tab, select Advanced and change ownership to you, if needed. Then you can change permissions to full control.

However, there may be a process locking the file, e.g. as at https://stackoverflow.com/questions/958123/powershell-script-to-check-an-application-thats-locking-a-file.

There are third-party tools such as LockHunter to help delete such files, too.

Share:
6,944
vamaddur
Author by

vamaddur

Updated on September 18, 2022

Comments

  • vamaddur
    vamaddur over 1 year

    I have this "main.cpp" file created in CodeBlocks, and I got rid of everything in the project folder, "NewDirections" except for this. I ran a del command through the command prompt as an administrator, shown in the following image, which did not work (it got an “Access is denied” error).

    del command fails (Access is denied) in administrator command prompt

    When I look at the file security under the properties header, I see this:

    You must have Read permission to see the properties of this object

    It is unable to display the owner.

    I tried another route to delete this pesky file by deleting the folder that contains it, but I get this error:

    Folder Access Denied
    You require permission from ASUS-K501UX\vamad_n1mu3mk to make changes to this folder

    (vamad_n1mu3mk is my username).

    According to the permissions, I have full access:

    VIRAJ MADDUR has “Full control” access to the “NewDirections” folder

    • Admin
      Admin over 6 years
      Did you mean, "Nonexistent?"
    • Admin
      Admin over 6 years
      Yes I did, @G-Man fixed it.
    • Admin
      Admin over 6 years
      In the interests of full disclosure, (1) YouKnowMe initially wrote “Nonexistant”; another editor changed it to “Nnnexistant”; and I changed it back.  (2) Nobody except jpaugh noticed that it should be “Nonexiste nt” (with an “e ” in the last syllable).
    • Admin
      Admin over 6 years
      (1) At the risk of asking a dumb question: are you sure ASUS-K501UX\vamad_n1mu3mk and “VIRAJ MADDUR ([email protected])” are the same account?  (Can you explain why it is displayed two different ways?)  (2) It might help us to understand this better if you describe exactly what happens when you click “Advanced” on the “Security” tab in the file “Properties” window.  (3) It might be useful to go back to the Administrator (elevated) Command Prompt, and do cd C:\Users\vamad_n1mu3mk\Desktop, dir/q and dir/q NewDirections (/q shows who owns things). … (Cont’d)
    • Admin
      Admin over 6 years
      (Cont’d) …  Feel free to leave out irrelevant information (e.g., the other things in your Desktop folder). (4) You might want to double-check that you’re really administrator by creating a file (copy nul foo is a good way to create an empty file) and checking that it is owned by Administrator (or Administrators) with dir/q and File Explorer.  (5) If you’re using some sort of domain administrator, you might want to look into using a local administrator account.
    • Admin
      Admin over 6 years
      I ended up using Lock Hunter after researching it to make sure it's trustworthy and it worked.
  • vamaddur
    vamaddur over 6 years
    I am not able to change ownership on "main.cpp", but I will look into the other 2 options...
  • vamaddur
    vamaddur over 6 years
    Trying to find the processes, if there are any, locking the file just gives the message "permission denied" when running the cmd prompt as an admin.
  • testeaxeax
    testeaxeax over 6 years
    @YouKnowMe You need to be an administrator to change ownership.
  • vamaddur
    vamaddur over 6 years
    I am an administrator for sure, I double checked this just now as well. However, there is a separate "local administrator account" which is empty since I never use it. The file does not show up when I login, since it is attached to my user.