我試過這個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錯誤的解釋。 –