740:请求的操作需要java中的提升
问题描述:
我试过这个java代码,在这段代码中,我将一个文件从一个目录移动到另一个目录,然后执行该文件, 。我正在使用Windows 7操作系统。740:请求的操作需要java中的提升
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import org.apache.commons.io.FileUtils;
import org.omg.CORBA.Environment;
public class JFileChooserTest {
public static void main(String[] args) {
String filelocation="C:\\Users\\FSSD\\Desktop\\OutPut\\Target\\setup.exe";
File trgDir = new File(filelocation);
System.err
.println("file location>>>>>>>>>>>>>>>>>>>"
+ filelocation);
File desDir = new File(
"C:\\Users\\FSSD\\IndigoWorkSpace\\Swing\\test");
try {
FileUtils.copyFileToDirectory(trgDir, desDir);
// FileUtils.copyDirectory(srcDir, trgDir);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
Runtime rt=Runtime.getRuntime();
try {
Process p=rt.exec("runas /user:FSSD test/setup.exe");
//Process p= rt.exec("test/setup.exe");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
虽然我执行此我得到“740:请求的操作需要提升”错误,如果有可能解决这个问题。
'setup.exe'被安装(或已被设置)到**运行作为管理员**([链接](http://windows-exe-errors.com/windows-error- 740-requested-operation-require-elevation /)) –
我不明白你想说什么 – Aerrow
请按照我刚刚提供的链接。有一个740错误的解释。 –