2011-08-19 138 views
0

我試過這個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:請求的操作需要提升」錯誤,如果有可能解決這個問題。

+0

'setup.exe'被安裝(或已被設置)到**運行作爲管理員**([鏈接](http://windows-exe-errors.com/windows-error- 740-requested-operation-require-elevation /)) –

+0

我不明白你想說什麼 – Aerrow

+0

請按照我剛剛提供的鏈接。有一個740錯誤的解釋。 –

回答

0

簡單的答案是,你不能在進程中進行。您需要啓動一個在命令行提升的新進程。 (請參閱升級命令)。

請參閱此問題和答案here - 他們解決您的問題。

0

服務主機本地系統的網絡限制10

HKEY_LOCAL_MACHINE> SYSTEM在右側面板,並雙擊它命名開始> ControlSet001

註冊表值。

Link