Jump to content

Take Ownership then Inherit


Recommended Posts

Hi,

Im trying to save some time and fix a permissions issue at work. I have a folder structure

D:\Users\username1\data

D:\Users\username2\data

D:\Users\username3\data

etc

Some of the files below "data" have incorrect permissions/ownership

I have written a send key script to kinda do this, this works until it comes across a folder that already has correct permissions/ownership then it fails

Run("explorer.exe " & "d:\users") 
WinWaitActive("D:\Users", "")
Send("{DOWN}")
Send("{UP}")
Send("!"& "{ENTER}")
WinWaitActive("", "File Folder")
;sleep (1000)
Send("+{TAB 2}")
Send("{RIGHT 2}")
WinWaitActive("", "Permissions for Administrators")
Send("!V")
WinWaitActive("", "Allow inheritable permissions")
Send("+{TAB }")
Send("{RIGHT 2}")
WinWaitActive("", "You can take or assign ownership")
Send("{TAB 2}")
Send("{SPACE}")
Send("!R")
sleep (1000)
Send("{TAB 2}")
Send("{ENTER}")
WinWaitActive("Security", "",5)
; this is where is stops if permissions are OK
Send("{ENTER}")
sleep (500)
Send("!V")
WinWaitActive("", "Allow inheritable permissions")
Send("!P")
Send("{TAB 2}")
Send("{ENTER}")
WinWaitActive("Security", "",5)
Send("{ENTER}")
WinWaitActive("", "Permissions for Administrators")
Send("{TAB}")
Send("{ENTER}")

So basically I want to take ownership of all the files/folders below D:\Users\username1\data then apply inherit permissions from D:\Users\username1\data down.

I have looked at the Takeown.exe command so could use that to take the permissions, but I cant work out how to do this for Username1 and then for Username2

Can anyone point me in the right direction please

Thanks

Bod

Link to comment
Share on other sites

Thanks billo

Does anyone know

Is it possible to get a @error or similar when I get to the line

WinWaitActive("Security", "",5)

so basically if the "Security" box doesnt appear then end the script/function

my script is for a one off job (that could save me 11 hours manual work) so im not looking for any thing special

Link to comment
Share on other sites

Bodman,

What if you used WinExist along with the WinWait something like this:

If Not WinExists("Security") Then

Exit

EndIf

jfcby

Determined -- Devoted -- Delivered Make your mind up -- to seriously apply yourself -- accomplishing the desired results. **** A soft answer turneth away wrath: but grievous words stir up anger. Proverbs 15:1 KJB ****

Link to comment
Share on other sites

Why don't you use SetACL.exe?

SetACL

This command changes the owner to the Administrators group.It propagates folders and files in the entire tree.

Commandline:

setacl.exe -on "d:\users" -ot file -actn setowner -ownr n:Administrators -rec cont_obj

Autoit:

runwait(@ScriptDir & "\SetACL.exe"  & ' -on "' &  'd:\users" -ot file -actn setowner -ownr n:Administrators -rec cont_obj', "", @SW_HIDE)

Read this for more info:

http://blog.bluebearr.net/2007/12/fixing-profile-permissions-in-windows.html

Edited by dobbelina
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
 Share

  • Recently Browsing   0 members

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