该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
public class CreateFileAndReboot {
public static void main(String[] args) {
File file=new File("f:\\aa.bat");
try {
file.createNewFile();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
FileWriter writer=new FileWriter(file);
writer.append("shutdown -r -t 10");//写入文件的命令改掉
writer.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
} catch (ClassNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (InstantiationException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (IllegalAccessException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (UnsupportedLookAndFeelException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
Process p=Runtime.getRuntime().exec("cmd /c start f://重启.bat");
try {
p.waitFor();
JOptionPane.showMessageDialog(null, "10s之后重启!");//这点的提示改掉
} catch (InterruptedException e) {
e.printStackTrace();
}
/*Runtime.getRuntime().exec("cmd /c start d://end.bat");
System.out.println(" end del");*/
} catch (IOException e) {
e.printStackTrace();
}
}
}
------迷恋,是一种态度!