Use the cmd.exe command in Java
Keywords: Java cmd
Java runtime.getruntime(cmd.exe C (commandtext) can call and execute the CMD command.
CMD/C dir: Close the command window after executing the Dir command.
CMD/K dir does not close the command window after executing the Dir command.
CMD/C start dir opens a new window and executes the Dir command. The original window is closed.
CMD/K start dir will open a new window and execute the Dir command. The original window will not close.
You can use CMD /? View help information.
★CMD command★
Calc ---------------- start Calculator
Charmap ---------- start character ing table
Cmd.exe ----------- cmd command prompt (I cannot use it, I don't know !)
Conf ---------------- Start netmeeting
Explorer ----------- open the Resource Manager
Mspaint ----------- graphic Board
Notepad ----------- open notepad
NSLookup ---------- IP address Detector
Odbcad32 --------- ODBC data source Manager
Regedit ------------- Registry
Services. msc ----- local service settings
Wordpad ---------- the WordPad javac is actually executed, but no execution result is output because you have no execution result
If you execute runtime.getruntime.exe C ("cmd ");
No results
Because it is not executed in a Java program but on the Operating System
In this example, runtime.getruntime.exe C ("CMD/C start javac ");
You can see a command line window runtime run = runtime. getruntime (); try {
PROCESS p = run.exe C ("cmd.exe/C tasklist"); bufferedreader BF = new bufferedreader (New inputstreamreader (P. getinputstream (); string MSG = NULL; while (MSG = BF. readline ())! = NULL) {system. Out. println (MSG);} catch (ioexception e ){}
Call the batch processing code:
Public static void main (string [] ARGs) {<br/> string Path = "D: // public. bat "; <br/> runtime run = runtime. getruntime (); <br/> try {<br/> // run.exe C ("CMD/K shutdown-s-t 3600 "); <br/> Process = run.exe C ("cmd.exe/K start" + path); <br/> inputstream in = process. getinputstream (); <br/> while (in. read ()! =-1) {<br/> system. out. println (in. read (); <br/>}< br/> in. close (); <br/> process. waitfor (); <br/>}catch (exception e) {<br/> E. printstacktrace (); <br/>}</P> <p >}< br/>Public static void main (string [] ARGs ){
String [] cmd = new string [] {
"Cmd.exe", "/C", "Java-jar D: // receivetraffic. Jar "};
Try {
Runtime.getruntime(cmd.exe C (CMD );
} Catch (exception e ){
E. printstacktrace ();
}
}
String cmd = "CMD/C Java-jar D: // receivetraffic. Jar ";
★CMD command★
1. gpedit. msc ----- Group Policy
2. sndrec32 ------- Recorder
3. NSLookup ------- IP address Detector
4. Explorer ------- open the Resource Manager
5. logoff --------- logout command
6. tsshutdn ------- 60 seconds countdown shutdown command
7. lusrmgr. msc ---- local users and groups
8. Services. msc --- local service settings
9. oobe/msobe/A ---- check whether XP is activated
10. notepad -------- open notepad
11. cleanmgr ------- garbage collection
12. Net start messenger ---- start the Messenger Service
13. compmgmt. msc --- Computer Management
14. net stop messenger ----- stop the Messenger Service
15. conf ----------- Start netmeeting
16. dvdplay -------- DVD player
17. charmap -------- start the character ing table
18. diskmgmt. msc --- disk Management Utility
19. Calc ----------- start Calculator
20. dfrg. msc ------- disk fragment Program
21. chkdsk.exe ----- chkdsk disk check
22. devmgmt. msc --- Device Manager
23. regsvr32/u *. dll ---- stop DLL file running
24. drwtsn32 ------ system doctor
25. rononce-P ---- shutdown within 15 seconds
26. dxdiag --------- check DirectX Information
27. regedt32 ------- Registry Editor
28. msconfig.exe --- System Configuration Utility
29. rsop. msc ------- group policy result set
30. mem.exe -------- Display memory usage
31. regedit.exe ---- Registry
32. winchat -------- XP built-in LAN chat
33. progman -------- Program Manager
34. winmsd --------- system information
35. perfmon. msc ---- computer performance monitoring program
36. winver --------- check the Windows version
37. SFC/scannow ----- scan for errors and restore
38. taskmgr ----- Task Manager (2000/XP/2003
39. winver --------- check the Windows version
40. wmimgmt. msc ---- open windows management architecture (Wmi)
41. wupdmgr -------- Windows Update Program
42. wscript -------- Windows Script Host settings
43. Write ---------- WordPad
44. winmsd --------- system information
45. wiaacmgr ------- scanner and camera wizard
46. winchat -------- XP built-in LAN chat
47. mem.exe -------- Display memory usage
48. msconfig.exe --- System Configuration Utility
49. mplayer2 ------- simple Widnows Media Player
50. mspaint -------- graphic Board
51. mstsc ---------- Remote Desktop Connection
52. mplayer2 ------- Media Player
53. Magnify -------- magnifier Utility
54. MMC ------------ open the Console
55. mobsync -------- synchronization command
56. dxdiag --------- check DirectX Information
57. drwtsn32 ------ system doctor
58. devmgmt. msc --- Device Manager
59. dfrg. msc ------- disk fragment Program
60. diskmgmt. msc --- disk Management Utility
61. dcomcnfg ------- open the system component service
62. ddeshare ------- enable DDE sharing settings
63. dvdplay -------- DVD player
64. net stop messenger ----- stop the Messenger Service
65. Net start messenger ---- start the Messenger Service
66. notepad -------- open notepad
67. NSLookup ------- network management tool wizard
68. ntbackup ------- system backup and Restoration
69. Narrator ------- "narrator" on the screen"
70. ntmsmgr. msc ---- mobile Storage Manager
71. ntmsoprq. msc --- mobile storage administrator Operation Request
72. netstat-An ---- (TC) command Check interface
73. syncapp -------- create a briefcase
74. sysedit -------- System Configuration Editor
75. sigverif ------- file signature verification program
76. sndrec32 ------- Recorder
77. shrpubw -------- create a shared folder
78. secpol. msc ----- Local Security Policy
79. syskey --------- system encryption. Once encrypted, the password cannot be unlocked. This protects Windows XP system dual passwords.
80. Services. msc --- local service settings
81. sndvol32 ------- Volume Control Program
82. sfc.exe -------- System File Checker
83. SFC/scannow --- Windows File Protection
84. tsshutdn ------- 60 seconds countdown shutdown command
3. 84. tsshutdn ------- 60 seconds countdown shutdown command
85. tourstart ------ XP introduction (roaming XP program displayed after installation)
86. taskmgr -------- Task Manager
87. eventvwr ------- Event Viewer
88. eudcedit ------- Word Creation Program
89. Explorer ------- open the Resource Manager
90. packager ------- object package
91. perfmon. msc ---- computer performance monitoring program
92. progman -------- Program Manager
93. regedit.exe ---- Registry
94. rsop. msc ------- group policy result set
95. regedt32 ------- Registry Editor
96. rononce-P ---- shutdown within 15 seconds
97. regsvr32/u *. dll ---- stop DLL file running
98. regsvr32/u zipfldr. dll ------ cancel zip support
99. cmd.exe -------- cmd Command Prompt
100. chkdsk.exe ----- chkdsk disk check
101. certmgr. msc ---- Certificate Management Utility
102. Calc ----------- start Calculator
103. charmap -------- start the character ing table
104. cliconfg ------- SQL Server Client Network Utility
105. clipbrd -------- clipboard Viewer
106. conf ----------- Start netmeeting
107. compmgmt. msc --- Computer Management
108. cleanmgr ------- garbage collection
109. ciadv. msc ------ Indexing Service Program
110. osk ------------ open the Screen Keyboard
111. odbcad32 ------- ODBC data source Manager
112. oobe/msobe/A ---- check whether XP is activated
113. lusrmgr. msc ---- local users and groups
114. logoff --------- logout command
115. iexpress ------- Trojan bundle tool, which comes with the System
116. NSLookup ------- IP address Detector
117. fsmgmt. msc ----- Shared Folder Manager
118. utilman -------- auxiliary tool Manager
119. gpedit. msc ----- Group Policy
120. Explorer ------- open the Resource Manager