package 练习;
import java.io.*;
public class Yyufuq {
public static void main(String args[]) {
try {Runtime ce = Runtime.getRuntime();
File file = new File("D:\\software\\WeGame","wegame.exe");
ce.exec(file.getAbsolutePath()) ;
}
catch(Exception e) {
System.out.print(e);
}
}
}
在cmd下操作了权限(百度上看的)好像没作用
NET LOCALGROUP
[groupname [/COMMENT:"text"]] [/DOMAIN]
groupname {/ADD [/COMMENT:"text"] | /DELETE} [/DOMAIN]
groupname name [...] {/ADD | /DELETE} [/DOMAIN]
C:\Users\羽甫青>net user
\\DESKTOP-0OGVKOH 的用户帐户
-------------------------------------------------------------------------------
Administrator DefaultAccount Guest
postgres WDAGUtilityAccount 羽甫青
命令成功完成。
C:\Users\羽甫青>
关闭你的eclipse,重新右键点击eclipse图标,然后点击:以管理员身份运行。
启动后,重新执行一下你的代码即可。
java.io.IOException: Cannot run program "D:\software\WeGame\wegame.exe": CreateProcess error=740, 请求的操作需要提升。
File file = new File("cmd /c D:\\software\\WeGame","wegame.exe");