java - Set write permissions on ProgramData subfolder using JNA -


itemprop = "text">

I have a program that is written in Java, which is basically all of its files in the program file Users program It is necessary for our users to run as administrator all the time. In an attempt to reduce it, we decided to move those files, which during the regular use of the ProgramData folder by using % ALLUSERSPROFILE% environment variable Need to be written. Using a subfolder in our directory works best for our application, if it is specified as writable during the installation process, which works fine using NSIS.

The problem comes with the upgrade of existing users, the Java file API provides setWritable but it does not work after testing on the development machines. It seems that the new file API with Java 7 will solve this problem, but I do not want to wait with any release date on the horizon.

It seems that simple solution would be to call JNA to upgrade the proper Windows API call software to set up this directory for writing in order that administrator rights are required to install It is similar, it should be let go of this change properly, however, I am not sure where to start or where the Windows API is never being used. The advice to do the work to load and call the Windows Library will be appreciated, especially if a person is facing similar problem.

Good, I'm glad you gave some background ... you can use JNA , But the command line utility would be the easiest way to call CCLL. This is included by default in Windows XP installation, I believe, so it should do the trick for you. Try Runtime.getRuntime (). Exec ("C: \\ Windows \\ System32 \\ cacls.exe" + Option)

View document here - & gt;

Comments