Runtime.getRuntime().exec("game\\s.exe")
Runtime.getRuntime().exec("cmd.exe /c start C:\\clean.bat(这个文件改成你做好的批处理文件)"); System.getProperties( "java.home");//获取java安装路径
Runtime.getRuntime().exec(
"taskkill /f /t /im java.exe"
); taskkill /f /im java.exe /t
windows : Runtime.getRuntime().exec('taskkill /F /IM abc.exe'); 帮助: 运行cmd输入taskkill -? linux: Runtime.getRuntime().exec('killall -9 abc.exe'); java中就是Runtime.getRuntime().exec("ntsd -c q -pn Notepad.exe"); java判断进程是否存在public boolean getProcess(){
boolean flag=false;
try{
Process p = Runtime.getRuntime().exec( "cmd /c tasklist ");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
InputStream os = p.getInputStream();
byte b[] = new byte[256];
while(os.read(b)> 0)
baos.write(b);
String s = baos.toString();
// System.out.println(s);
if(s.indexOf( "Besttone.exe ")>=0){
System.out.println( "yes ");
flag=true;
}
else{
System.out.println( "no ");
flag=false;
}
}catch(java.io.IOException ioe){
}
return flag;
}
//杀掉进程
public
static
void
main(String[] args)
{
try
{
String[] cmd =
{
"tasklist"
};
Process proc = Runtime.getRuntime().exec(cmd);
BufferedReader in =
new
BufferedReader(
new
InputStreamReader(proc
.getInputStream()));
String string_Temp = in.readLine();
while
(string_Temp !=
null
)
{
System.out.println(string_Temp);
if
(string_Temp.indexOf(
"notepad.exe"
)!=-
1
)
Runtime.getRuntime().exec(
"Taskkill /IM notepad.exe"
);
string_Temp = in.readLine();
}
}
catch
(Exception e)
{
}