Bodman Posted May 14, 2010 Share Posted May 14, 2010 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 More sharing options...
l3ill Posted May 14, 2010 Share Posted May 14, 2010 Hi Bod, what you are doing is going to be a lot more stable if you make use of some of the more advanced features of AutoIT. Have a look at the "If Then Loop" and "GUICtrlRead". Good luck! My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example Link to comment Share on other sites More sharing options...
Bodman Posted May 14, 2010 Author Share Posted May 14, 2010 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 More sharing options...
l3ill Posted May 14, 2010 Share Posted May 14, 2010 If WinExists("AutoIt Help") Then MsgBox(0, "", "Window exists") Else MsgBox(0, "", "Window doesnt exist") Exit EndIf My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example Link to comment Share on other sites More sharing options...
jfcby Posted May 14, 2010 Share Posted May 14, 2010 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 More sharing options...
dobbelina Posted May 14, 2010 Share Posted May 14, 2010 (edited) Why don't you use SetACL.exe?SetACLThis 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_objAutoit: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 May 14, 2010 by dobbelina Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now