Jump to content

Recommended Posts

Posted

Hello,

it's possible to code in autoit those information in this page :

http://www.blogsdna.com/2159/how-to-take-ownership-grant-permissions-to-access-files-folder-in-windows-7.htm

Thanks in advance for you help

Posted

yes you can. If you noticed they show a different way to do this with a context click. It involves modifying the registry and then context clicking on the file you want to take ownership of. It would be a simple matter then to make an adjustment to the reg file they provide you so one could use an AutoIt script to do what you have in mind.

Posted

To set permissions or take ownership of files/folders, I always use the program SetACL and embed that in my exe with FileInstall. Works better than xcalcs with file/folder inheritance. I can't remember why now though, but there was an article somewhere about it.

Posted (edited)

Try this:

;Coded by UEZ 2010
#RequireAdmin
$objWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\.\root\cimv2")

$file = FileOpenDialog("Select file to reset ownership from current user.", "", "(*.*)")
If @error Then Exit
$res = Set_OwnerShip($file)
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $res = ' & $res & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console

Func Set_OwnerShip($file)
    $file = StringReplace($file, "\", "\\")
    Local $colItems, $colItem
    $colItems = $objWMIService.ExecQuery("Select * From CIM_DataFile Where Name = '" & $file & "'", "WQL", 0x30)
    If IsObj($colItems) Then
        For $objItem In $colItems
            $objItem.TakeOwnerShipEx
        Next
        Return 1
    Else
        Return SetError(1, 0, 0)
    EndIf
EndFunc

Or try the command line subinacl from Microsoft.

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Posted (edited)

Couple of subinacl eg

you will obviously need the subinacl exe to make this work

$source = "your source dir"
$subinacl = @WorkingDir & "\subinacl.exe"

RunWait(@ComSpec & " /c " & $subinacl & " /subdirectories " & $source & "*.*" & " /setowner=" & @UserName)
RunWait(@ComSpec & " /c " & $subinacl & " /subdirectories " & $source & "*.*" & " /grant=" & @UserName & "=f")

and ive done attrib this way before

If FileExists ( $source & "Perflogs") Then FileSetAttrib( $source & "Perflogs", "-H", 1)
Edited by Chimaera
Posted (edited)

I can't change the title...

How can I do that also to delete a registry key?

Edited by ricky03
Posted

Deleting a registry key: RegDelete()

You might also try using icacls.exe (at least that's what I use for Windows Server 2008+) :mellow:

Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
  • 2 weeks later...
Posted

Nobody can help me ?

@Hannes123 : do you have examples?

Deleting a registry key: RegDelete()

Sometimes it doesn't work, because I don't have the right and I use #requireadmin

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...