Sign in to follow this  
Followers 0
SamCobb

Directory/Folder operations

5 posts in this topic

I am trying to find a way to script a solution to resetting ownership on folder and their files/folders below in a Windows 2003 environment. I am surprised not to find some of this functionality in AutoIT.

Thanks

Share this post


Link to post
Share on other sites



Not my field, but does the stuff in Net Share management udf do what you want it to?

William

Share this post


Link to post
Share on other sites

Some but it's still very limited.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Try this (WMI version):

;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
Set_OwnerShip($file)

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 SetError(0)
    Else
        Return SetError(1)
    EndIf
EndFunc

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
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
Sign in to follow this  
Followers 0