Search code examples
javawindowssecuritypermissionsjava-web-start

How to obtain administrator rights in java web start application, need to writting in system directories


I'm going to develop a java web start application, which need to access protected system directory and install a program there.

I know, how to exit sandbox, my application is signed and have access to filesystem. The problem is, that it sill can't access directories like C:/windows/system32.

I found solutions for standalone java applications: Java: run as administrator

How to do this in java web start?

Thanks in advance for answer!


Solution

  • In your case you can probably try to use the following trick:

    1. Precompile a jar file with the Manifest pointing to the main class, that carries out all of the required filesystem routines

    2. Put this jar somewhere into the resources folder of your Web-Start application and then copy it into the user's Temp folder upon Web-Start execution

    3. Provision required files from the elevation PowerToys in the similar manner

    4. Call " %PATH_TO_USER_TEMP%/elevate" command together with "java -jar %PATH_TO_USER_TEMP%/yourJar.jar" (please refer to the article above or additional documentation on the Elevation PowerToys to find out the details)

    5. If everything works out, user shall be presented with a request to grant the executed java process required Admin privileges.