CreateProcess error=740, The requested operation r

2020-01-27 07:20发布

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?

标签: java
6条回答
等我变得足够好
2楼-- · 2020-01-27 07:30

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.

查看更多
小情绪 Triste *
3楼-- · 2020-01-27 07:35

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

查看更多
手持菜刀,她持情操
4楼-- · 2020-01-27 07:43

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 ....)

查看更多
Fickle 薄情
5楼-- · 2020-01-27 07:47

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.

查看更多
▲ chillily
6楼-- · 2020-01-27 07:47

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:

  1. Kill adb.exe, kill eclipse.exe from task manager in windows.
  2. Close eclipse and disconnects your phone and restart it and disable USB debugging and enable it again.
  3. Go to eclipse icon right click and choose run as administrator
  4. Connect it to your device and run your application.

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

查看更多
甜甜的少女心
7楼-- · 2020-01-27 07:49

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!

查看更多
登录 后发表回答