Jump to content

ICAcLs & TakeOwn Command Line


 Share

Recommended Posts

Hi all,

 

I'm trying to do the following steps:

 

1. Ask the user to select a File from a dialog window "Open" (save its original owner and permissions) and also a UserName from the dialog window "Select User or Group" and grant the ownership and full access of the File to the UserName.

 

2. Wait for the user to finish accessing the File.

 

3. Automatically return the original owner and permissions (the one that saved in step 1) back to the File.

 

Using the following commands:

 

TakeOwn /F "full path of the File"

 

ICAcLs "full path of the File" /Grant "UserName":F

 

ICAcLs "full path of the File" /SetOwner "original user"

 

ICAcLs "full path of the File" /Grant:R "original user":RX

 

 

Any help will be appreciated.  :idea:  :idea:  :idea: 

 

TIA

Link to comment
Share on other sites

DIR /Q will give you the owner; but if you are not the owner and you have no access to the file, then you may have difficulty to restore the ownership after you've taken it (i have not tried it),

this is a good summary for ICACLS (the lettercase is flexible, but if you insist, then at least the middle ACL must be uppercase ;) )

http://ss64.com/nt/icacls.html

anyway, where are you stuck with your script?

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

DIR /Q will give you the owner; but if you are not the owner and you have no access to the file, then you may have difficulty to restore the ownership after you've taken it (i have not tried it),

this is a good summary for ICACLS (the lettercase is flexible, but if you insist, then at least the middle ACL must be uppercase ;) )

http://ss64.com/nt/icacls.html

anyway, where are you stuck with your script?

Thanx for the quick reply.

The 4 commands line with its sequence, will do the job exactly the way I wonted (in DOS prompt) with no error or conflict in ownership!

ACL = Access Control List

ICAcLa = Inegrated Control Access List  B)

I did not yet started with the script! May be someone has it laying somewhere in his archive. I think I have to get rid of my old dusty AutoIt information and start the coding..! :ph34r:

Link to comment
Share on other sites

The 4 commands line with its sequence, will do the job exactly the way I wonted (in DOS prompt) with no error or conflict in ownership!

 

happy for you. did you test on files that are not accessible to you? i find this is the main issue with ownership - users take ownership and revoke admin rights on files and folders... very annoying.

I did not yet started with the script! May be someone has it laying somewhere in his archive. I think I have to get rid of my old dusty AutoIt information and start the coding..! :ph34r:

 

look up RunWait() in AutoIt help.

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

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