Search code examples
javawindowsaclcaclsinstall4j

How to change the file ACL in windows, if I only know the SID?


I want to change the ACL of a file and set "full permissions" to a special user.

I know the cacls-command cacls . /e /t /p Everyone:f

But this only works if the OS is english. For german systems, it must be cacls . /e /t /p Jeder:f.

I know the well-known SIDs of the user "everyone" (S-1-1-0), but it seems as if I can't use them with cacls.

I tried cacls . /e /t /p S-1-1-0:f.

Is there a way to use windows command line tools for this jobs? I'm not allowed to bundle software or other commandline tools for this job with my software.

The solution has to be called from a Java-Process, but that should not be a problem.


Solution

  • I found a solution. I am using a library from the vendor of my Setup creation tool.

    edit:

    Solution for problem:

    The Setup-Creation Tool Install4j has a method getUserLogin(String sid) its returnvalue is something like: WORKSTATION1\User1

    I used cacls to change the ACL.