-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRecover.java
More file actions
117 lines (110 loc) · 2.4 KB
/
Recover.java
File metadata and controls
117 lines (110 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.OutputStream;
import java.io.Writer;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class Recover extends JFrame implements ActionListener
{
JButton b, select;
JFileChooser chooser;
String a1 = "cd /d ";
String a2 = "";
String a3 = "attrib -s -h -r /D /S ";
String a4 = "del /S *.lnk ";
JLabel lab;
File file;
void wrong()
{
lab.setText("First Choose a folder");
}
void correct()
{
lab.setText("");
}
void del()
{
file.delete();
}
void make()
{
b = new JButton("clickme");
select = new JButton("Choose");
lab = new JLabel();
setLayout(new FlowLayout());
add(b);
add(select);
add(lab);
setSize(300,400);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setVisible(true);
b.addActionListener(this);
select.addActionListener(this);
}
public static void main(String af[])throws Exception
{
JFrame myFrame = new JFrame("Shortcut Remover");
Recover r = new Recover();
r.make();
}
@Override
public void actionPerformed(ActionEvent e)
{
if(e.getSource().equals(b))
{
try{
if(a2.equals(""))
{
wrong();
}
else
{
file = new File(a2+"vb.bat");
OutputStream fos = new FileOutputStream(file);
fos.write(a1.getBytes());
fos.write(a2.getBytes());
fos.write(13);
fos.write(10);
fos.write(a3.getBytes());
fos.write(13);
fos.write(10);
fos.write(a4.getBytes());
fos.write(13);
fos.write(10);
fos.close();
Process p = Runtime.getRuntime().exec(a2+"vb.bat");
p.waitFor();
del();
}
}catch(Exception ea){
System.out.println("exception"+ea);
}
}
else
{
int result;
chooser = new JFileChooser();
chooser.setCurrentDirectory(new java.io.File("."));
chooser.setDialogTitle("select");
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
//
// disable the "All files" option.
//
chooser.setAcceptAllFileFilterUsed(false);
//
if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
a2 = chooser.getCurrentDirectory().toString();
correct();
}
else {
}
}
}
}