1
2
3
4 package net.sf.ovanttasks.ovnative.demos;
5
6 import java.io.File;
7 import net.sf.ovanttasks.ovnative.win32.LnkFile;
8 import net.sf.ovanttasks.ovnative.win32.Win32;
9
10
11
12
13
14
15
16 public class LnKFileOnDesktop {
17
18
19
20
21
22 public static LnkFile resolveCmdOnDesktop() {
23 LnkFile lnkFile = new LnkFile(Win32.SpecialDirectory.PERSONAL_DESKTOP.getPath(), "open command shell in temp (resolve)", false);
24 lnkFile.setTargetFile(Win32.getWindowsSystemDirectory() + "X"+ File.separator + "cmd.exe");
25 lnkFile.save();
26 lnkFile.resolve();
27
28 LnkFile lnkFile1 = new LnkFile(lnkFile.getSrcFile(), true);
29 lnkFile1.setArguments("/K dir /N /Q");
30 if (!lnkFile1.getSrcFile().getAbsolutePath().equals(Win32.getWindowsSystemDirectory() + File.separator + "cmd.exe")) {
31
32 }
33 return lnkFile;
34 }
35
36
37
38
39
40 public static LnkFile createCmdOnDesktop() {
41 LnkFile lnkFile = new LnkFile(Win32.SpecialDirectory.PERSONAL_DESKTOP.getPath(), "list TEMP", false);
42 lnkFile.setToolTipText("Open command shell in %TEMP% \n and execute command dir /N /Q");
43 lnkFile.setHotkey("Ctrl + Alt + A");
44 lnkFile.setIcon(Win32.getWindowsDirectory() + File.separator + "explorer.exe", 3);
45
46 lnkFile.setShowState(LnkFile.ShowCmd.SHOWMAXIMIZED);
47 lnkFile.setTargetFile(Win32.getWindowsSystemDirectory() + File.separator + "cmd.exe");
48 lnkFile.setArguments("/K dir /N /Q");
49 lnkFile.setWorkingDirectory(Win32.SpecialDirectory.TEMP.getPath());
50
51 lnkFile.save();
52 return lnkFile;
53 }
54
55
56
57
58
59 public static LnkFile createCmdInProgramMenu() {
60 LnkFile lnkFile = new LnkFile(Win32.SpecialDirectory.PERSONAL_PROGRAMS_MENU.getPath(), "open command shell in temp", false);
61 lnkFile.setTargetFile(Win32.getWindowsSystemDirectory() + File.separator + "cmd.exe");
62 lnkFile.setArguments("/K dir /N /Q");
63
64 lnkFile.save();
65 return lnkFile;
66 }
67
68
69
70
71
72 public static LnkFile createExporerOnDesktop() {
73 LnkFile lnkFile = new LnkFile(Win32.SpecialDirectory.PERSONAL_DESKTOP.getPath(), "start explorer", false);
74 lnkFile.setTargetFile(Win32.getWindowsDirectory() + File.separator + "explorer.exe");
75 lnkFile.setArguments(Win32.SpecialDirectory.PROGRAM_FILES.getPath());
76 lnkFile.save();
77 return lnkFile;
78 }
79
80
81
82
83
84
85 public static void main(String[] args) throws Exception {
86 createCmdOnDesktop();
87 createExporerOnDesktop();
88 resolveCmdOnDesktop();
89 createCmdInProgramMenu();
90 }
91
92
93
94
95 public static void cleanup() {
96 createCmdOnDesktop().getSrcFile().delete();
97 createExporerOnDesktop().getSrcFile().delete();
98 resolveCmdOnDesktop().getSrcFile().delete();
99 createCmdInProgramMenu().getSrcFile().delete();
100 }
101 }