Reputation: 3042
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?
Upvotes: 19
Views: 65884
Reputation: 1
I've also faced this problem, But when tried to run Runtime.getRuntime().exec(filepath)
with prefix
"cmd /c " to the file path it worked perfectly
Your code should like Runtime.getRuntime().exec("cmd /c <filepath>")
Note: filepath-the complete directory list required to locate the file
in my code:
String filepath="C:\\Users\\MSI\\Downloads\\AutomationInstaller.exe"
Upvotes: 0
Reputation: 1
If you problem is with Android Studio then killing any instance of adb.exe solves.
Upvotes: -1
Reputation: 509
I've faced such problem too when tried to run app with command:
cmd /c start <exe_file>
This command could not run executable that require Admin access. Instead use of
rundll32 url.dll,FileProtocolHandler <exe_file>
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 returns java.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.
Upvotes: 2
Reputation: 19
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 ....)
Upvotes: 0
Reputation: 102
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
Upvotes: 0
Reputation: 37
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!
Upvotes: 2
Reputation: 381
When using .exec(cmd)
, prefix your command with cmd /c
so you end up with something like rt.exec("cmd /c <your command>")
. This will launch the process and invoke the UAC if needed.
Upvotes: 34