Is there a way in Java to ask the system get control over the system. Without doing: Right click on an exe-> run as admin. What I want is that there comes a frame from uac like in windows vista or windows 7. Or have I to do some settings while making an exe from the jar?
+4
A:
You have to create a manifest file that specifies that your application needs administrator permissions. You can include the manifest in your exe or keep it as a separate file (yourapp.exe.manifest)
ZippyV
2009-09-06 15:11:14
The problem of course is that the "executable" will be the JVM, not your own code. And since the manifest applies to the JVM, it applies to anything run by that JVM.
MSalters
2009-09-08 10:59:18
What if you have a wrapper exe which launches java? Will the administrator access be inherited by the child process (jvm)?
Cal
2009-10-22 03:01:03
+1
A:
ZippyV's answer is fine if you intend to launch the javaw.exe with system admin privileges, which if pure java code is what is getting blocked by the UAC (such as trying to write a file to a privileged directory), then that is what you will need to do.
If, however, you are trying to launch something external, but just with elevation, you could bundle an exe which elevates a command. Here is one.
Yishai
2009-09-06 15:17:03