Jump to content

Win7 file Security and Ownership


ardi

Recommended Posts

I've had horrible results trying to get ownership and control over files. I'm the only user/admin yet sometimes I cannot change ownership of files brought from a flash drive. One error I get is "cannot determine current owner." So I can't use or delete files I've just imported.

Really, what I'm looking for is a very good resource to study. I know it's out there, and someone knows what to do when the thing does not respond as described. What is the nuclear option to get control of files?

Link to comment
Share on other sites


Or you could try this script to take ownership of the file

Save As OwnTheFile.vbs


Dim Act : Set Act = CreateObject("Wscript.Shell")
Dim Obj
For Each Obj in Wscript.Arguments
Act.Run("takeown /f " & Obj),0,True
Act.Run("icacls " & Obj & " /grant administrators:F"),0,True
Next

Link to comment
Share on other sites

Attachment in post three is a multi-lingual right click shell extension version.

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 *S-1-5-32-544:F"
"IsolatedCommand"="cmd.exe /c takeown /f \"%1\" && icacls \"%1\" /grant *S-1-5-32-544: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 *S-1-5-32-544:F /t"
"IsolatedCommand"="cmd.exe /c takeown /f \"%1\" /r /d y && icacls \"%1\" /grant *S-1-5-32-544:F /t"

S-1-5-32-544 is the well-known sid of the "Administrators" local group. So this should work as well.


Dim Act : Set Act = CreateObject("Wscript.Shell")
Dim Obj
For Each Obj in Wscript.Arguments
Act.Run("takeown /f " & Obj),0,True
Act.Run("icacls " & Obj & " /grant *S-1-5-32-544:F"),0,True
Next

Edited by MrJinje
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...