Java runtime.getruntime (). EXEC (COMMANDSTR) can invoke the Execute CMD command.
cmd/c dir closes 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 will open a new window and execute the dir instruction, the original window will be closed.
cmd/k start dir will open a new window and execute the dir instruction, the original window will not be closed.
You can use cmd/? To view help information.
★cmd command ★1. Gpedit.msc-----Group Policy 2. SNDREC32-------Recorder 3. Nslookup-------IP Address detector 4. Explorer-------Open Explorer 5. Logoff---------logoff command 6. TSSHUTDN-------60-second Countdown shutdown command 7. Lusrmgr.msc----native users and Groups 8. Services.msc---Local Service settings 9. oobe/msoobe/a----Check if XP is active 10. Notepad--------Open Notepad 11. cleanmgr-------Garbage Disposal 12. net start Messenger----Start 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 character mapping table 18. Diskmgmt.msc---Disk Management utility 19. Calc-----------Start Calculator 20. Dfrg.msc-------Disk Defragmenter 21. Chkdsk.exe-----CHKDSK disk check 22. Devmgmt.msc---Device Manager 23. regsvr32/u *.dll----Stop DLL file to run 24. DRWTSN32------System Doctor 25. Rononce-p----15 second shutdown 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--------shows memory usage 31. Regedit.exe----Registration Form 32. Winchat--------XP comes with LAN Chat 33. ProgMan--------Program Manager 34. WINMSD---------System Information 35. PERFMON.MSC----Computer performance monitoring Program 36. Winver---------Check Windows version 37. sfc/scannow-----Scan for errors and revert to 38. Taskmgr-----Task Manager (2000/xp/2003 39. Winver---------Check Windows version 40. Wmimgmt.msc----Open Windows Management Architecture (WMI) 41. wupdmgr--------Windows Update 42. wscript--------Windows Script Host Settings 43. Write----------WordPad 44. WINMSD---------System Information 45. Wiaacmgr-------Scanner and Camera Wizard 46. Winchat--------XP comes with LAN Chat 47. Mem.exe--------shows memory usage 48. Msconfig.exe---System Configuration Utility 49. Mplayer2-------Easy widnows Media Player 50. MSPaint--------Drawing Board 51. MSTSC----------Remote Desktop Connection 52. Mplayer2-------Media Player 53. Magnify--------Magnifier Utility 54. MMC------------to open console 55. Mobsync--------Synchronization Command 56. DxDiag---------Check DirectX information 57. DRWTSN32------System Doctor 58. Devmgmt.msc---Device Manager 59. Dfrg.msc-------Disk Defragmenter 60. Diskmgmt.msc---Disk Management utility 61. DCOMCNFG-------Open System Components service 62. DdeShare-------turn on DDE sharing settings 63. Dvdplay--------DVD Player 64. net stop Messenger-----Stop the Messenger Service 65. net start Messenger----Start Messenger Service 66. Notepad--------Open Notepad 67. nslookup-------Network Management Tool Wizard 68. ntbackup-------system backup and restore 69. Narrator-------Screen Narrator 70. Ntmsmgr.msc----Mobile Storage Manager 71. Ntmsoprq.msc---Mobile Storage Administrator action Request 72. NetstatThe-an----(TC) command checks for interface 73. Syncapp--------Create a briefcase 74. Sysedit--------System Configuration Editor 75. Sigverif-------File Signature Validator 76. Sndrec32-------Recorder 77. SHRPUBW--------Create a shared folder 78. Secpol.msc-----Local Security Policy 79. SYSKEY---------System encryption, once encrypted can not be unlocked, the protection of Windows XP system dual password 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-second Countdown shutdown command 3. TSSHUTDN-------60-second Countdown shutdown command 85. Tourstart------XP profile (Roaming XP program that appears after installation is complete) 86. Taskmgr--------Task Manager 87. EVENTVWR-------Event Viewer 88. Eudcedit-------Word-font procedure 89. Explorer-------Open Explorer 90. Packager-------Object Wrapper 91. PERFMON.MSC----Computer Performance monitoring program 92. ProgMan--------Program Manager 93. Regedit.exe----Registration Form 94. Rsop.msc-------Group Policy result set 95. Regedt32-------Registry Editor 96. Rononce-p----15 second shutdown 97. regsvr32/u *.dll----Stop DLL file to run 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 character mapping table 104. CLICONFG-------SQL SERVER Client Network Utility 105. CLIPBRD--------Clipboard Viewer 106. Conf-----------start NetMeeting 107. Compmgmt.msc---Computer Management 108. cleanmgr-------Garbage Disposal 109. CIADV.MSC------Indexing Service Program 110. Osk------------turn on On-screen Keyboard 111. ODBCAD32-------ODBC data Source Manager 112. oobe/msoobe/a----Check if XP is active 113. Lusrmgr.msc----native users and Groups 114. Logoff---------Logoff command 115. IExpress-------Trojan Bundle tool, System comes with 116. Nslookup-------IP Address detector 117. Fsmgmt.msc-----shared Folder Manager 118. Utilman--------Utility Manager 119. Gpedit.msc-----Group Policy 120. Explorer-------Open Resource Manager
Call Batch code:
Java code
- Public static void main (string[] args) {
- String Path = "D:\\public.bat";
- Runtime run = Runtime.getruntime ();
- try {
- //Run.exec ("cmd/k shutdown-s-T 3600") ;
- Process process = Run.exec ("cmd.exe/k start" + path);
- InputStream in = Process.getinputstream ();
- While (in.read ()! =-1) {
- System.out.println (In.read ());
- }
- In.close ();
- Process.waitfor ();
- } catch (Exception e) {
- E.printstacktrace ();
- }
- }
Go: Java call cmd command