1

I had an installation of a software called npm (known for its infamous deep and extensive directory structures) on my older Windows (inside G:\users\username\appdata). After I removed the older Windows I am attempting to remove the G:\users\username\ directory.

Since the folder is owned by a user on my older Windows, I should first take ownership of the directories and then remove them, but the problem is that the security tab in explorer "folder properties" could not take ownership of the folders (would give errors that I later found is the result of deep directory structures). Even other utilities (e.g. TakeOwnershipPro) would only work on shallower sub-folders and fail on deeper ones.

How should I take ownership and remove the folders and files?

1

This is the solution I found after a few days:

  • Open a Powershell in administrator mode (this will not work in normal CMD with administrative rights)

  • CD drive:\directory (i.e. go to the root folder where the sub-directories that you want to remove reside

  • Take ownership of the sub directories recursively:

    takeown /f * /r /a

  • Now remove everything recursively:

    rm -r *

P.S.: If you still have problem and you have windows 10, enable path names longer than 260 characters. Use gpedit and the guide at the bottom of this page: https://www.howtogeek.com/266621/how-to-make-windows-10-accept-file-paths-over-260-characters/ , then restart and try above procedure.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.