import java.io.*;
import java.util.*;
public class RuntimeDemo {
public static void main(String args[]) throws IOException
{
//Runtime.getRuntime().exec("msconfig");
Runtime.getRuntime().exec("mspaint");
}
}
为什么mspaint能在eclipse下运行出来,而msconfig却运行不出来?
网友告诉我说只有能在cmd中运行的命令才能在exec(command)中运行出来,那怎样才能使msconfig运行出来呢?
import java.util.*;
public class RuntimeDemo {
public static void main(String args[]) throws IOException
{
//Runtime.getRuntime().exec("msconfig");
Runtime.getRuntime().exec("mspaint");
}
}
为什么mspaint能在eclipse下运行出来,而msconfig却运行不出来?
网友告诉我说只有能在cmd中运行的命令才能在exec(command)中运行出来,那怎样才能使msconfig运行出来呢?
Runtime.getRuntime().exec("C:\\WINDOWS\\pchealth\\helpctr\\binaries\\msconfig.exe"); 这样就可以了
或者你设下path
或如楼上所说写全路径,写当前的可以将msconfig文件拷贝至当前文件夹即可。