JAVA开发--U盘EXE恢复工具

原理比较简单,在学校机房U盘总被感染,写一个工具来方便用

 

  1 package com.udiskrecover;
  2 
  3 import java.awt.Container;
  4 import java.awt.FlowLayout;
  5 import java.awt.GridLayout;
  6 import java.awt.event.ActionEvent;
  7 import java.awt.event.ActionListener;
  8 import java.io.IOException;
  9 
 10 import javax.swing.JButton;
 11 import javax.swing.JFrame;
 12 import javax.swing.JLabel;
 13 import javax.swing.JOptionPane;
 14 import javax.swing.JTextField;
 15 import javax.swing.text.AbstractDocument.Content;
 16 
 17 /*
 18  ############################################################
 19  #                                                             #
 20  #      【名称】 : U盘EXE恢复工具                                 #
 21  #      【作者】 : Sevck(一个写代码很帅的男人)                     #
 22  #      【团队】 : 网络尖刀                                      #
 23  #      【主页】 : http://sevck.lofter.com                      #
 24  #      【日期】 : 2015-10-15                                   #
 25  #      【功能】 : 将磁盘上病毒引起的感染EXE通过DOS恢复             #
 26  #                                                            #
 27  ############################################################
 28  #   ┏┓   ┏┓
 29  #┏┛┻━━━┛┻┓
 30  #┃            ┃
 31  #┃     ━      ┃
 32  #┃  ┳┛  ┗┳  ┃
 33  #┃             ┃
 34  #┃ ``` ┻   ```┃
 35  #┃             ┃
 36  #┗━┓      ┏━┛
 37  #####┃      ┃Code is far away from bug with the animal protecting.
 38  #####┃      ┃神兽护佑,代码无Bug.
 39  #####┃      ┗━━━━━┓
 40  #####┃                ┣┓
 41  #####┃                ┏┛
 42  #####┗┓┓┏━┳┓┏┛
 43  #######┃┫┫  ┃┫┫
 44  #######┗┻┛  ┗┻┛
 45  ############################################################
 46  */
 47 public class UDiskRecover extends JFrame {
 48 
 49     JLabel label;
 50     JTextField text;
 51     JButton submit;
 52     String reg = "[a-zA-Z]{1}";
 53 
 54     public UDiskRecover() {
 55         init();
 56     }
 57 
 58     public void init() {
 59         Container cp = this.getContentPane();
 60         label = new JLabel("请输入要恢复的磁盘:");
 61         text = new JTextField(10);
 62         submit = new JButton("确定");
 63         cp.add(label);
 64         cp.add(text);
 65         cp.add(submit);
 66         
 67         this.setSize(300, 200);
 68         this.setVisible(true);
 69         this.setDefaultCloseOperation(3);
 70         //this.setLocationRelativeTo(null);
 71         this.setTitle("U盘EXE恢复工具--By:Sevck");
 72         this.setLayout(new FlowLayout(1, 20, 30));
 73         this.setResizable(false);
 74         submit.addActionListener(new ActionListener() {
 75 
 76             @Override
 77             public void actionPerformed(ActionEvent e) {
 78                 // TODO Auto-generated method stub
 79 
 80                 String content = text.getText();
 81                 boolean z = content.matches(reg);
 82                 Process process = null;
 83                 if (z) {
 84                     String cmd = "cmd.exe /c attrib -s -h -r " + content
 85                             + ":\\\\* /s /d";
 86                     // String cmd="cmd.exe /c move d:\\1.txt e:\\";
 87                     // String cmd="cmd.exe /c move d:\\1.txt e:\\";
 88                     // System.out.println(newcon);
 89                     // System.out.println(cmd);
 90                     try {
 91                         process = Runtime.getRuntime().exec(cmd);
 92                         System.out.println(process.toString());
 93                         JOptionPane.showMessageDialog(null, "文件恢复成功!");
 94                     } catch (IOException e1) {
 95                         // TODO Auto-generated catch block
 96                         e1.printStackTrace();
 97                         JOptionPane.showMessageDialog(null, "文件恢复失败!");
 98                     }
 99                 } else {
100                     JOptionPane.showMessageDialog(null,
101                             "请输入正确的盘符!\r\n提示:a-z||A-Z,不需要写“:”.");
102                 }
103             }
104         });
105 
106     }
107 
108     public static void main(String[] args) {
109         new UDiskRecover();
110     }
111 }

 

posted @ 2015-10-20 18:01  sevck  阅读(511)  评论(0编辑  收藏  举报