Simple 7 Q: How do I change ownership of multiple files at once?

Viper GTS

n00b
Joined
Jun 12, 2006
Messages
63
I recently wiped my machine and upgraded from XP x64 to 7 Ultimate x64. I'm now having difficulty accessing some of the data on my storage drives. I want to force ownership changes on all files on the drives to resolve any lingering traces of my previous machine/security accounts.

The problem is when I select multiple files I don't have a security tab. I can change attributes of one file at a time but when two files or folders are selected I only have General + Customize (in the case of folders) or General + Details (files).

What am I missing? Do I need to figure out how to elevate an explorer window?

Apparently this was a momentary lapse of intelligence, doing it one level higher on the drive itself gives me what I want. Carry on.

Viper GTS
 
Last edited:
I'm not in front of w7 right now, but in most windows versions its:
Right click on drive letter, properties -> security -> advanced -> owner.
 
The source of my confusion was a UI change in 7 (and probably 2008). In XP + Server 2003 you could change security settings for multiple files at once. In 7/2008 it's one object at a time, to get everything on a drive you can step up a level to the drive itself and push changes through the tree.

IMO this is a reduction in functionality, since if you wanted to do say 1/2 the folders on a storage volume you'd have do to individual operations for each since there is no point higher to push it from.

Viper GTS
 
Found a really great tip/tweak for Windows 7 the other day...

Add a "Take Ownership" option to the right-click context menu in Explorer by creating a Registry file (Notepad, save as *.reg) with the following text which you can copy and paste:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell\runas]
@="Take Ownership"
"NoWorkingDirectory"=""

[HKEY_CLASSES_ROOT\*\shell\runas\command]
@="cmd.exe /c takeown /f \"%1\" && icacls \"%1\" /grant administrators:F"
"IsolatedCommand"="cmd.exe /c takeown /f \"%1\" && icacls \"%1\" /grant administrators:F"

[HKEY_CLASSES_ROOT\Directory\shell\runas]
@="Take Ownership"
"NoWorkingDirectory"=""

[HKEY_CLASSES_ROOT\Directory\shell\runas\command]
@="cmd.exe /c takeown /f \"%1\" /r /d y && icacls \"%1\" /grant administrators:F /t"
"IsolatedCommand"="cmd.exe /c takeown /f \"%1\" /r /d y && icacls \"%1\" /grant administrators:F /t"

After that you'll have a nice addition to the right-click menu. The only downside is (take a deep breath) if you use it, it'll pop up a UAC prompt because it needs elevation, obviously, but then it'll pop up an Admin Command Prompt window that's there then gone, in a split second.

The secondary downside is that if you do this for multiple files, you've got to do it over and over again so, obviously you don't want to use this with a bunch of files (read: hundreds, thousands, etc... bad idea). :D

Solution? Put the specific files in a folder and take ownership of the folder itself, it'll propragate down through the folders and the files inside inherit the ownership. It'll still ask for the permission, but this time you only have to do it that one time; the Command Prompt will stay up as the changes whiz by... when it's done, it disappears, all done.

Good luck...
 
Yeah theres probably some overly-complicated way to do it in powershell.

edit - lol I knew it would be ugly:
$objUser = New-Object System.Security.Principal.NTAccount("domain", "login name")
$objFile = Get-Acl C:\Scripts\Test.txt
$objFile.SetOwner($objUser)
Set-Acl -aclobject $objFile -path C:\Scripts\Test.txt

But hey you could use an array of filenames and go through each one in a loop and...ok this is way over-engineered.
 
Last edited:
I'm not in front of w7 right now, but in most windows versions its:
Right click on drive letter, properties -> security -> advanced -> owner.

I just checked and this works. I was having problems with accessing files and I added myself and granted all permissions. That worked but ths allows me to own the drives.

I don't remember having this problem with other upgrades.
 
Before I go and do something I will regret, who should the actual owner of the disks be. The current owner of my c: drive is TrustedInstaller. I started to change it to my user profile but decided I'd better ask first.
 
Easy, change the parent folder and, unless you changed it before, all sub folders should inherit permissions.
 
the administrator account that you can't fubar the password on or delete by accident is the best account to own the files. Do NOT take ownership of encrypted files unlock them first, unless you want to lose them. :)
 
Before I go and do something I will regret, who should the actual owner of the disks be. The current owner of my c: drive is TrustedInstaller. I started to change it to my user profile but decided I'd better ask first.

alot of folders will have the administrators group as the owner. but things created by the installer will have the owner of trustedinstaller. Only reason why you would need to change that to administrators would be if the administrators group does not have full access.
 
alot of folders will have the administrators group as the owner. but things created by the installer will have the owner of trustedinstaller. Only reason why you would need to change that to administrators would be if the administrators group does not have full access.

I did a little checking and I was about to screw up. You need to leave the ownership as trustedinstaller on the c: drive to keep from screwing up things. I did add myself as an user and gave full permission.

Now I hope I didn't screw up by taking ownership of the other drives.
 
well done i never knew that (looked it up my self) :) you should be fine for the other drives though.
 
Back
Top