I have a web applet that I update regularly and I finally decided to make an updater. However when I download an update in java it downloads fine. However when I try to unpack + run the update by using Runtime.getRuntime().exec(pathToFile);
I get CreateProcess error=740, The requested operation requires elevation
How can I fix this if the program is a web applet? I can't just tell them to run their browsers as administrators. How can i fix this?
When using
.exec(cmd)
, prefix your command withcmd /c
so you end up with something likert.exec("cmd /c <your command>")
. This will launch the process and invoke the UAC if needed.One of my friends was having this exact same problem about a month ago (he was unrolling an update via a .exe file), and I remember that this link helped him tremendously: http://mark.koli.ch/2009/12/uac-prompt-from-java-createprocess-error740-the-requested-operation-requires-elevation.html
I would make this simply a comment under your question (doesn't seem worthy of a straight up answer/solution), but I don't have enough rep yet to comment. :-P
I had the same issue, resolve it by running the java application as an administrator, to make it permanent: Right click on your application , go to property > Compatibility > check "Run this program as an administrator"
(I have a batch file runs Java.exe -jar ....)
I've faced such problem too when tried to run app with command:
This command could not run executable that require Admin access. Instead use of
command solved my problem. This command triggers UAC prompt, so user could provide correct access before app will be launched.
In my app I used
PrecessBuilder::start()
function. This function returnsjava.lang.Process
instance which will be alive (process.isAlive() == true
) until user will handle UAC prompt, so it's better to add some loop to wait until it happens to consider for sure that app is launched.Reason:
When you try to run your application, your IDE attempts to start adb but it ends up getting 740 process error or adb down because your IDE is not allowed to run an adb.exe file from your platform tools in your sdk folder.
Solution:
A golden tip - always run your eclipse,sdk manager,command prompt as administrator so your system gives full permission to specific application.
tested on window 7 64bit
device Samsung 4.4 eclipse ide
One Manual work around one of our engineers found, if it is not your application, start a cmd prompt, right click on the window and click the "Run as Administrator" menu item. in my case running the .jnlp file work!