Skip to content
⌘ NSIS Forum Archive

Wrapping installer for UAC and Java

3 posts

kalverson#

Wrapping installer for UAC and Java

When a Java process tries to directly launch a Nullsoft install process and the default UAC setting is on, the Java runtime throws a 740 exception. Java can't perform elevation. To get around this, I created a wrapper program to call ShellExecute with the "runas" verb which is the same thing as running as Administrator. The wrapper program is asInvoker which can be launched by the Java Runtime and lets the new ShellExecute process do the elevation for Administrator. A coworker suggested that the Nullsoft setup installer be directly wrapped inside the launcher instead of doing it separately. I'm wondering if Nullsoft could have this functionality added because otherwise doing it that way would complicate the build process? Of course, one can just make their own helper exe which is what I did and that works in the mean time.
Anders#
If the manifest in a .exe specifies administrator or highest then you don't need to force the runas verb, ShellExecute with a NULL verb is enough.

Putting something inside the wrapper doubles the disk space usage when running and you lose the elevation overlay icon in Explorer...
LoRd_MuldeR#
To launch executable that requires elevation from Java, try something like:
Runtime.getRuntime().exec(new String[] {"cmd.exe", "/k", "C:\\Redist\\Installer.exe"});