![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-08-10 22:01 |
47,811 topics / 349,897 posts / today 0 new / 48,256 members |
| DOS学习入门 & 精彩文章 (教学室) » Collection of DOS Command Tips |
| Printable Version 5,850 / 23 |
| Floor1 自由人 | Posted 2002-12-31 00:00 |
| 初级用户 Posts 15 Credits 169 | |
|
Batch processing has many techniques and can accomplish many things that can't be done well in Windows.
@echo off //Cancel the display of command operation on the screen echo. |date| find "Current" //Only display the date echo. |time| find "Current" //Only display the time :: //Equivalent to rem call //Call another batch file del %0 //Self - delete if "%1" == "string" goto //For example, if "%1" == "/p" goto p if "%1" == "string" command //if "%1" == "/p" dir /w/p c: if exist file command //Run the command if the file exists copy /b //Merge files fdisk /mbr //Uninstall the master boot record. If the master boot record is overwritten by LILO, it can be used to clear it prompt $p$g //Restore the prompt echo Free and Open > new DOS.txt //Write Free and Open into new DOS.txt echo Happy New year >> new DOS.txt //Continue to write Happy New year into new DOS.txt lh //Load the device into the upper memory. For example, lh smartdrv /x mode 80 Restore the default display settings mode mono Activate the monochrome display mode con:cols=40-80 lines=25-50 //40-80;25-50 are parameters Keyboard control mode con:rate=32 delay=1 //Agile mode con:rate=20 delay=4 //Accurate mode con:rate=20 delay=2 //Default Print control mode com1:9600,8,N,1 //Fast mode lpt1=com1 mode com1:2400,8,N,1 //Slow mode lpt1=com1 echo Hello > prn //Test printing Install CD - ROM Add in config.sys devicehigh=boot\CD-ROM.sys /d MSCD001 Add in autoexec.bat path boot mscdex /d MSCD001 /m 12 //CD-ROM.sys can be replaced by universal CD - ROM IDE.sys //Menu display, selection echo 1. echo 2. echo 3. ... echo 9. choice /c:123456789 /n Please choose: if errorlevel 9 goto 9 if errorlevel 8 goto 8 if errorlevel 7 goto 7 if errorlevel 6 goto 6 if errorlevel 5 goto 5 if errorlevel 4 goto 4 if errorlevel 3 goto 3 if errorlevel 2 goto 2 if errotlevel 1 goto 1 A simple example @echo off if "%1" == "/all" goto all If exist c:\1.txt goto 1 echo The file 1.txt is not found goto end :1 echo The file 1.txt exists, press any key to read... pause > nul type 1.txt | more goto end :all dir /s/w/p 1.txt :: Display all 1.txt in the sub - directories of the C drive :end |
|
| Floor2 nre | Posted 2002-12-31 00:00 |
| 银牌会员 Posts 361 Credits 1,210 | |
|
Not bad~ But I hope to classify them again, because this way is not convenient for searching and learning.
Ask a question: How to use DEL %0? Correct some improper places above. FDISK/MBR does not delete the MBR (Master Boot Record), but overwrites the current MBR content with the default master boot record. copy /b alone cannot achieve merging. /B specifies merging in binary mode, and /A is for ASIIC files. copy file1 + file2 +... fileN target file choice, mode, more are all external commands. When compiling BAT, if these commands are used, it is necessary to consider whether the file exists. |
|
| Floor3 自由人 | Posted 2003-01-01 00:00 |
| 初级用户 Posts 15 Credits 169 | |
|
Thanks to NRE for pointing out the inappropriate parts. Add "del %0" at the end of the batch file, and it will self-delete after completion. Most of the above commands can be directly inserted and used in the batch file. It's just that only a part of the skills and less commonly used command parameters are listed, and there are many more to be listed after I sort them out. Of course, if anyone has questions in this regard, I will be happy to answer for you.
|
|
| Floor4 nre | Posted 2003-01-01 00:00 |
| 银牌会员 Posts 361 Credits 1,210 | |
|
This is the first time I've seen this usage of DEL. Classic~
I tried it, and %0 stores the file name of the called file, excluding the extension. So you need to add the extension. del %0.bat to achieve automatic deletion. But when doing this, after running, there will be a prompt of BATCH FILE MISSING. |
|
| Floor5 tanglu_sd | Posted 2003-01-01 00:00 |
| 高级用户 Posts 271 Credits 948 From sd | |
|
How is the virtual disk created after booting with the built-in startup disk of Win98?
|
|
| Floor6 小臣 | Posted 2003-01-06 00:00 |
| 初级用户 Posts 6 Credits 123 | |
|
What is the function of DEL %0 self-deletion????
|
|
| Floor7 小臣 | Posted 2003-01-06 00:00 |
| 初级用户 Posts 6 Credits 123 | |
|
According to your writing, in DOS, do you need to install UCDOS?
|
|
| Floor8 小臣 | Posted 2003-01-06 00:00 |
| 初级用户 Posts 6 Credits 123 | |
|
Who can teach me under DOS, I only know how to use FDISK CD DIR DEL SCANDISK MD RD and other commands. Is there any other ones for DOS masters??? Please give more more more guidance!
|
|
| Floor9 MYS | Posted 2003-01-06 00:00 |
| 元老会员 Posts 1,637 Credits 5,170 From 广东佛山 | |
|
There are still many.
diskcopy msav xcopy smartdrv help deltree format sys ... |
|
| Floor10 Wengier | Posted 2003-01-06 00:00 |
| 系统支持 Posts 10,521 Credits 27,736 | |
|
The command DEL %0 is quite problematic because the %0 parameter actually returns the command line used to execute this batch file. For example, when I want to execute the ABC.BAT batch file, I can enter ABC or ABC.BAT on the command line to execute it. In this way, the value of %0 may be completely different, that is, its value may be "ABC" or "ABC.BAT", etc. And if it is the former, DEL %0, that is, DEL ABC, is impossible to delete the ABC.BAT itself.
|
|
| Floor11 redtek | Posted 2006-09-29 06:17 |
| 金牌会员 Posts 1,147 Credits 2,902 | |
|
Then execute two lines:
DEL %0 DEL %0.BAT Write both, there will always be one that can delete itself normally~:) |
|
| Floor12 electronixtar | Posted 2006-09-29 07:27 |
| 铂金会员 Posts 2,672 Credits 7,493 | |
| Floor13 redtek | Posted 2006-09-29 07:47 |
| 金牌会员 Posts 1,147 Credits 2,902 | |
|
Original note: When deleting a directory name with spaces, there were no quotes in the DEL command :) Execution: It was deleted~ :) Thanks to electronixtar for the wonderful %~f0 code, I learned a lot more~ :) Later, the comment for for /? : %~fI - Expand %I to a fully qualified pathname This %~f0 is really wonderful~ :) |
|
| Floor14 jieok3375 | Posted 2006-09-30 03:52 |
| 中级用户 Posts 130 Credits 282 From 广东 | |
|
Learning
|
|
| Floor15 winzip126 | Posted 2006-10-23 23:24 |
| 新手上路 Posts 6 Credits 18 | |
|
Bookmarked
|
|
| 1 2 Next |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |