真是见鬼啊! 当年在学校写的一个破程序,竟然被到处转,nnd。。。。。。。。
java 代码
- import java.io.IOException;
- public class CtrWDS {
- private static CtrWDS ourInstance = null;
- private CtrWDS() {
- }
- public static CtrWDS getInstance() {
- if (ourInstance == null) {
- ourInstance = new CtrWDS();
- }
- return ourInstance;
- }
- public void exec(String cmd) {
- try {
- Runtime.getRuntime().exec("shutdown "+cmd);
- }
- catch (IOException e) {
- System.out.println("执行失败");
- }
- }
- public void shutdown() {
- exec("shutdown -S ");
- }
- public void restart() {
- exec("shutdown -R ");
- }
- public void logout() {
- exec("shutdown -L ");
- }
- public static void main(String[] str) {
- if (str.length == 0) {
- System.out.println("-----------------------\n" +
- "关机 -s\n" +
- "重起 -r\n" +
- "注销 -l\n" +
- "-----------------------\n");
- }
- else{
- try{
- CtrWDS.getInstance().exec(str[0]);
- Thread.currentThread().sleep(10000L);
- }
- catch(Exception e){
- //CtrWDS.getInstance().exec(str[0]);
- }
- }
- }
- }