8

I have a file that's created by a program, and apparently an interaction with the system and Google Backup & Sync somehow scrambles the owner and permissions of the file. (The owner shows up as either "Unknown" or "Unable to display current owner", depending on where I look at it.)

I need to reclaim ownership of the file.

The standard method (from the File Explorer right click, Properties, Security tab, Advanced, Change Owner) doesn't work because I don't have permission to do that. Basically I need super user access on my own system so I can override what the OS thinks and actually administrate the file.

Anyone got a clue? Rebooting seems to clear the issue but that's a crappy solution. I have a Cygwin shell on this system if that helps. I'd prefer to not have to download any special utilities unless the source is very trustworthy.

Edit The problem re-occured. So far I'm not able to set the owner of the offending files:

C:\Users\Brenden>icacls "C:\Users\Brenden\Google Drive\proj\tempj8\build   \classes\quicktest\AbstractTest.class" /SETOWNER "%username%" /c
C:\Users\Brenden\Google Drive\proj\tempj8\build\classes\quicktest\AbstractTest.class: Access is denied.
Successfully processed 0 files; Failed processing 1 files

C:\Users\Brenden>

This command fails too:

C:\WINDOWS\system32>takeown /F "C:\Users\Brenden\Google Drive\proj\tempj8\build\classes\quicktest\AbstractTest.class"
ERROR: Access is denied.

C:\WINDOWS\system32>
5
  • markspace - Try these two commands and tell me if this helps solve: icacls "C:\folder\path\file.txt" /SETOWNER "%username%" /C and then takeown /F "C:\folder\path\file.txt".... If this helps, tag me back as @PimpJuiceIT and I'll add this information along with some additional detail plus some reference sources for further learning. Jul 11, 2018 at 2:30
  • The first command you gave me didn't work: see my edit but it says "Access is denied." Any other ideas? @PimpJuiceIT
    – markspace
    Oct 9, 2018 at 23:59
  • @PimpJuiceIT Just tried takeown by itself in a command prompt and it fails also.
    – markspace
    Oct 10, 2018 at 0:57
  • Read over this post and look over some of the commands if states to run with options and such. I think perhaps running takeown /f "C:\Users\Brenden\Google Drive\*.*" /r /a /d y and then ICACLS "C:\Users\Brenden\Google Drive\*.*" /reset /T /C /L /Q may help but look over all the thread and what people say does work for some. It's likely a security setting at a higher level up parent folder wise that needs to be reset or whatever but not sure if you could disable inheritance from `"C:\Users\Brenden\Google Drive` and then set the security but another thought I had. Oct 10, 2018 at 2:14
  • Oh.... here's the post too by the way: social.technet.microsoft.com/Forums/windows/en-US/… Oct 10, 2018 at 2:15

3 Answers 3

7

Try:

Taking ownership of a file or folder from command line

Open an elevated Command Prompt window.

To do so:

a. Go to > Start > All Programs > Accessories

b. Right-click on Command Prompt, and then click Run as Administrator.

c. Type the following command and press Enter key:

takeown /f [path to folder] /r /d y

d. Then assign the Administrators group Full Control Permissions for the folder, use this command and hit Enter key:

icacls [path to folder] /grant administrators:F /T 

The /T parameter is added so that the operation is carried out through all the sub-directories and files within that folder.

3
  • This also says "access denied" even though I ran it as administrator and got the little "Are you sure you want let this app make changes to your device?" pop up.
    – markspace
    Oct 10, 2018 at 0:11
  • The grant administrators full rights didn't work for me, but the reset argument works: icacls found.000 /reset /t. Jun 7, 2020 at 2:58
  • The /T parameter is added so that the operation is carried out through all the sub-directories and files within that folder. ~ * ~ Thanks! I was missing the /T flag and wondered why it didn't work for me. ~ * ~ I would vote this answer up again if I could … Nov 15, 2022 at 12:57
3

1. A one-liner to take full control – normal situations

Hit WinKey+r, type cmd, hold down Ctrl+Shift and press Enter. 1

Then run : 2

takeown /f CompatTelRunner.exe /a
 && icacls CompatTelRunner.exe /grant Administrators:f

I rather strongly recommend running
dir /q CompatTelRunner.exe & icacls CompatTelRunner.exe
both before and after the one-liner – to display how the ownership and permissions on the file change.

For a more elaborated treatise, see this answer on how to restore the TrustedInstaller on C:\Windows\System32\CompatTelRunner.exe.

2. Your situation is different though

The standard method (from the File Explorer right click, Properties, Security tab, Advanced, Change Owner) doesn't work because I don't have permission to do that.

– Yes. Using the File Explorer (GUI) to take ownership is as you describe :
right-click the file and click Properties > Security > Advanced > Change > type/paste Administrators > Check Names > OK.

But when doing this you report getting "Access is denied" (and likewise when running takeown in the command line). The reason might be that Google Backup & Sync (or some other application) has locked the file you want to change the ownership of.

2a. First suggestion: try external software

I'd prefer to not have to download any special utilities unless the source is very trustworthy.

– If you trust the services of VirusTotal (I do), then you could try downloading and installing LockHunter. Here is a link to the VirusTotal verdict of LockHunter version 3.4.3 . I just installed LockHunter on my own laptop. According to the LockHunter official website, it's a foolproof file unlocker. My lacking experience of it though, means I personally cannot say much about whether it's useful or not.

2b. Second suggestion: restart Windows

Just restart Windows and see if that solves the problem.

2c. Third suggestion: restart in safe mode

If all else fails, try restarting in safe mode. – Press WinKey+r, type msconfig and hit Enter.

In the System Configuration window that opens, click the Boot tab, and then check Safe boot as shown in the screenshot below. Click OK to restart in safe mode.

System Configuration > Boot > Safe boot > OK.

When you later want to leave safe mode and restart normally, use the same procedure as before (msconfig) – but this time uncheck Safe boot and click OK to restart.

References


1 Holding down Ctrl+Shift makes the command prompt open as administrator.

2 I use the file C:\Windows\System32\CompatTelRunner.exe as an example. Of course, replace with your file of interest.

1
  • 1
    Thanks for the complete information. As an update, I haven't had this issue in a while (like over two years at least). There have been several updates to both Windows and Google Backup by then, someone may have figured out what they were doing wrong. Also while this issue was occurring, a restart would always fix the issue, so no need for safe mode. Thanks again!
    – markspace
    Jul 30, 2022 at 15:23
0

I've had an issue with file ownership before.

Follow this tutorial. It worked like a charm for me.

  • Open File Explorer, and then locate the file or folder you want to take ownership of.

  • Right-click the file or folder, click Properties, and then click the Security tab.

  • Click the Advanced button. The "Advanced Security Settings" window will appear. Here you need to change the Owner of the key. Click the Change link next to the "Owner:" label

  • The Select User or Group window will appear. Select  the user account via the Advanced button or just type your user account in the area which says 'Enter the object name to select' and click OK.

  • Optionally, to change the owner of all subfolders and files inside the folder, select the check box "Replace owner on subcontainers and objects" in the "Advanced Security Settings" window. Click OK to change the ownership.

  • Now you need to provide full access to the file or folder for your account. Right-click the file or folder again, click Properties, and then click the Security tab.

  • Click the Add button. The "Permission Entry" window will appear on the screen:

  • Click "Select a principal" and select your account:

  • Set permissions to "Full control":

  • Click OK.

4
  • Chris, to make this a self-contained answer, please summarize or quote at least the essentials from that tutorial (and keep the link to that useful article). Jul 10, 2018 at 22:16
  • I'm on mobile right now, so I'll have to do several edits to meet the guideline. I'll remember that from now on.
    – Chris
    Jul 10, 2018 at 22:19
  • 1
    I specifically mentioned this in my OP. It doesn't work. At the point where I click Change next to the Owner, it says I'm not allowed to do that. So no doesn't work.
    – markspace
    Jul 10, 2018 at 22:23
  • @markspace I'm blind. I'll do some more research when I get back to my computer and I'll update you if I can figure another method, if it's still unsolved. Sorry about that
    – Chris
    Jul 10, 2018 at 22:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .