|
MYS
元老会员
        
积分 5170
发帖 1637
注册 2002-10-16 来自 广东佛山
状态 离线
|
『楼 主』:
转贴:DOS批处理文件的妙用
使用 LLM 解释/回答一下
DOS批处理文件的妙用
在大多数计算机使用者的机器中的操作系统有两种:Windows和DOS。
Dos黑黑的界面,命令行的输入方式,不能和Windows相提并论。但是现在有很多的应用程序还是基于Dos设计的,在Dos下才能发挥最好的状态,所以我们还需要Dos。
Dos不很好用,可又要用它,解决这个总是只有一个办法:加强它的功能!Dos的批处理文件就是其中的一种。
批处理文件就好像是一个宏,它是一个文本文件,其中包括的都是一些标准的Dos命令,当然还有一部分是批处理的专用控制命令。批处理文件的扩展名是bat,Dos的命令处理文件(command.com)规定批处理文件为可执行文件。只要在命令行中键入bat文件名,Dos就会一条一条地执行bat中的语句。功能就相当于在命令行打入每条命令。批处理的语句通过不同的组合,会有很意想不到的效果。下面我会用一些实例来向大家说明。
1.我们在路径设置时,如原来有路径,就会被新的覆盖。如不想覆盖,就一定要在命令行中连新路径、旧的路径一起打出来,好累啊!看看下边的程序吧:
@echo off
if “%1”== “” GOTO END
set path=%path%
path %1;%path%
:END
说明:
%1:第一个形参,内容是要加的路径。如无内容,则结束。
2. 一些软件在使用时,要么有路径指向它,要么就是在当前目录运行。因为这种软件只在当前的和指定的路径查找数据一类的附助文件,所以,如没有路径指向和不在当前路径,程序会说“找不到文件”。那把所有的路径加入到环境变量PATH中不就可以了吗?理论上说来是可以是,但Dos有一个限制,命令行字符数总和不可以超过127个。而PATH又是要以命令行来执行的,结果可想而知,如果超过,Dos会毫不犹豫地告诉你:环境变量溢出!
如果你想在执行完上面这种程序后再回到原路径,看看下边的程序:
@echo off
set tmppath=%path%
set path=%1
%2
path=%tmppath%
set tmppath=
说明:
%1:第一个形参。为要运行软件的路径,一定要写全。
%2:第二个形参。软件运行文件名。
3.程序异常退出、中文系统花屏,怎么办?用批处理也可以解决。
这个批处理程序使用了Dos提供的几个命令。
@echo off
PROMPT $P$G
MODE CO80
KEYB US,437
ECHO
The Wonderful Use of DOS Batch Files
There are two types of operating systems in most computer users' machines: Windows and DOS.
The dark interface of DOS and the command-line input method cannot be compared with Windows. But now there are many applications still designed based on DOS, which can perform best under DOS, so we still need DOS.
DOS is not very easy to use, but we have to use it. The only way to solve this problem is to enhance its functions! The DOS batch file is one of them.
A batch file is like a macro. It is a text file that contains some standard DOS commands and also some special control commands for batch processing. The extension of a batch file is.bat. The DOS command processor (command.com) specifies that a batch file is an executable file. As long as you type the.bat file name in the command line, DOS will execute the statements in the.bat one by one. The function is equivalent to entering each command in the command line. Through different combinations of batch processing statements, there will be very unexpected effects. I will use some examples to illustrate to you below.
1. When we set the path, if there was an original path, it will be overwritten by the new one. If we don't want to overwrite, we must type both the new path and the old path in the command line, which is very tiring! Look at the following program:
@echo off
if "%1" == "" GOTO END
set path=%path%
path %1;%path%
:END
Explanation:
%1: The first parameter, the content is the path to be added. If there is no content, it ends.
2. Some software, when in use, either has a path pointing to it or runs in the current directory. Because such software only looks for auxiliary files such as data in the current and specified paths, so if there is no path pointing and not in the current path, the program will say "File not found". Then, can we add all paths to the environment variable PATH? Theoretically, it is possible, but DOS has a limit that the total number of characters in the command line cannot exceed 127. And PATH is to be executed by the command line, and the result is predictable. If it exceeds, DOS will unhesitatingly tell you: Environment variable overflow!
If you want to return to the original path after executing the above kind of program, look at the following program:
@echo off
set tmppath=%path%
set path=%1
%2
path=%tmppath%
set tmppath=
Explanation:
%1: The first parameter. It is the path of the software to be run, and it must be written completely.
%2: The second parameter. The file name for software operation.
3. What to do if the program exits abnormally or the Chinese system has a screen garble? It can also be solved with batch processing.
This batch processing program uses several commands provided by DOS.
@echo off
PROMPT $P$G
MODE CO80
KEYB US,437
ECHO
|

我的网志
http://hzmys.blog.163.com/
我的网盘
firststep.qjwm.com
fsmys.ys168.com
ssmys.ys168.com
www.brsbox.com/fsmys
www.brsbox.com/ssmys
www.brsbox.com/ccdos
|
|
2002-10-25 00:00 |
|
|
hit
初级用户
  孤胆枪手
积分 688
发帖 148
注册 2002-10-26 来自 陕西
状态 离线
|
|
2002-10-26 00:00 |
|
|
Wengier
系统支持
             “新DOS时代”站长
积分 27736
发帖 10521
注册 2002-10-9
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
好像个人电脑上的操作系统基本上只有三类吧,一种是DOS类,包括各种DOS,以及运行于DOS之上的Win3.x/9x等;第二种是OS/2、WinNT类,包括OS/2、WinNT/2K/XP/.Net等;第三种是Unix类,包括各种Unix、Linux、FreeBSD等等。
It seems that there are basically three types of operating systems on personal computers. One type is the DOS - related ones, including various DOS and Win3.x/9x running on DOS; the second type is OS/2, WinNT - related ones, including OS/2, WinNT/2K/XP/.Net, etc.; the third type is the Unix - related ones, including various Unix, Linux, FreeBSD and so on.
|

Wengier - 新DOS时代
欢迎大家来到我的“新DOS时代”网站,里面有各类DOS软件和资料,地址:
http://wendos.mycool.net/
E-Mail & MSN: wengierwu AT hotmail.com (最近比较忙,有事请联系DOSroot和雨露,谢谢!)
 |
|
2002-10-26 00:00 |
|
|
copy114
初级用户
 
积分 229
发帖 37
注册 2002-11-9
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
@echo off
set tmppath=%path%
set path=%1
%2
path=%tmppath%
set tmppath=
我看了几次了,但还是不明白,你们能不能说详细的跟我解释一下这些命令的意思啊?
@echo off
set tmppath=%path%
set path=%1
%2
path=%tmppath%
set tmppath=
I've read it several times, but I still don't understand. Can you explain the meanings of these commands in detail for me?
|
|
2002-11-28 00:00 |
|
|
okghost
初级用户
 
积分 140
发帖 14
注册 2002-11-11
状态 离线
|
『第 5 楼』:
[注意]
使用 LLM 解释/回答一下
为什么你的连接是空的,难道……
Why is your connection empty, could it be...
|
|
2002-11-30 00:00 |
|
|
superdos
中级用户
  
积分 272
发帖 43
注册 2003-4-4
状态 离线
|
|
2003-4-4 00:00 |
|
|
zgzjwz
初级用户
 
积分 227
发帖 28
注册 2004-5-15
状态 离线
|
|
2004-5-18 00:00 |
|
|
willsort
元老会员
         Batchinger
积分 4432
发帖 1512
注册 2002-10-18
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
Re Wengier:
为什么不把MacOS包含在内呢?
Re MYS:
1,例子一完全可以简化为 set path=%1;%path%;DOS7以上甚至可以直接在命令行中这样使用。
2,"一些软件在使用时,要么有路径指向它,要么就是在当前目录运行。因为这种软件只在当前的和指定的路径查找数据一类的附助文件"
指定路径的原因在于DOS解释器载入可执行程序的机制,而非软件程序本身的路径问题。而且基本上没有什么程序从%path%路径中查找"数据"文件,数据文件的查找路径早期被设定在append路径中,后期则是由程序自身确定。
3,"命令行字符数总和不可以超过127个。而PATH又是要以命令行来执行的,结果可想而知,如果超过,Dos会毫不犹豫地告诉你:环境变量溢出"
在命令行中无法输入超过限制的命令行字符数,即使通过其它方法超过,也不一定会造成环境变量溢出,这取决于环境变量声誉空间的大小。所以"毫不犹豫"一说不妥。
4,"Mode CO80将屏幕显示方式恢复成为“黑白80×25”模式"
-------------------------------------
CO40或CO80
指定激活彩色监视器的彩色功能,并指定每行的字符数。(注意监视器的类型)
-------------------------------------
5,"Echo
Re Wengier:
Why is MacOS not included?
Re MYS:
1, Example one can be simplified to set path=%1;%path%; DOS 7 and above can even be used directly in the command line like this.
2, "Some software, when used, either has a path pointing to it or is run in the current directory. Because such software only looks for auxiliary files such as data in the current and specified paths"
The reason for specifying the path is due to the mechanism by which the DOS interpreter loads executable programs, not the path problem of the software program itself. And basically, few programs look for "data" files from the %path% path. The search path for data files was early set in the append path, and later determined by the program itself.
3, "The total number of command line characters cannot exceed 127. And PATH is to be executed by the command line, so the result is obvious. If it exceeds, Dos will unhesitatingly tell you: Environment variable overflow"
It is impossible to enter a command line character count exceeding the limit in the command line. Even if it is exceeded by other methods, it does not necessarily cause an environment variable overflow, which depends on the size of the environment variable reputation space. So the statement "unhesitatingly" is inappropriate.
4, "Mode CO80 restores the screen display mode to the "black and white 80×25" mode"
-------------------------------------
CO40 or CO80
Specify to activate the color function of the color monitor and specify the number of characters per line. (Note the type of monitor)
-------------------------------------
5, "Echo
|

※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得! |
|
2004-5-19 00:00 |
|
|
Kinglion
铂金会员
       痴迷DOS者
积分 5798
发帖 1924
注册 2003-6-20 来自 金獅電腦軟體工作室
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
To willsort:
我真服了你了,你发的贴子没有一个是灌水的.建议你常来论坛来看看.帮助大家来解决问题.我也希望能向你请教一些问题.
To willsort:
I really admire you. None of the posts you made are water posts. It is suggested that you often come to the forum to have a look. Help everyone solve problems. I also hope to ask you some questions.
|

熟能生巧,巧能生精,一艺不精,终生无成,精亦求精,始有所成,臻于完美,永无止境!
金狮電腦軟體工作室愿竭诚为您服务!
QQ群:8393170(定期清理不发言者)
个人网站:http://www.520269.cn
电子邮件:doujiehui@vip.qq.com
微信公众号: doujiehui
|
|
2004-5-20 00:00 |
|
|
zhri
高级用户
    zhri
积分 665
发帖 153
注册 2004-2-23
状态 离线
|
|
2004-5-22 00:00 |
|
|
nacncyclone
初级用户
 
积分 105
发帖 1
注册 2004-5-22
状态 离线
|
|
2004-5-23 00:00 |
|
|
ati2004
初级用户
 
积分 139
发帖 9
注册 2004-5-23
状态 离线
|
|
2004-5-23 00:00 |
|
|
wjt_lily
初级用户
 
积分 110
发帖 2
注册 2004-5-23
状态 离线
|
『第 13 楼』:
使用 LLM 解释/回答一下
好久没有用DOS了,但很怀念那个时代,专一和高效!
Haven't used DOS for a long time, but I miss that era, single-mindedness and efficiency!
|
|
2004-5-23 00:00 |
|
|
robinxie
初级用户
 
积分 127
发帖 7
注册 2004-3-7
状态 离线
|
『第 14 楼』:
使用 LLM 解释/回答一下
有没有更深入一点的批处理命令使用.据我所知它的功能很大,在外国的一些黑客们用它来进行攻击,并且在国外流行的程序大战中,使用批处理命令是相当频繁的,而且实用.
Are there any more in-depth uses of batch commands. As far as I know, its functions are very powerful. Some hackers abroad use it for attacks, and in the popular program battles abroad, the use of batch commands is quite frequent and practical.
|
|
2004-5-23 00:00 |
|
|
SagInvoker
初级用户
 
积分 257
发帖 38
注册 2004-5-20
状态 离线
|
『第 15 楼』:
使用 LLM 解释/回答一下
RE ROBINXIE
我觉得你不应该问有多少批处理命令,而应该问问你知道多少DOS命令,
批处理的专用控制流程的命令就那么几个if for call choice echo pause rem goto shift
然后就没了,你如果不去学学哪些关于网络的DOS命令,你也不会理解你所说的什么黑客用它来攻击的问题.
RE ROBINXIE
I think you shouldn't ask how many batch processing commands there are, but should ask how many DOS commands you know. The special control flow commands for batch processing are just a few: if, for, call, choice, echo, pause, rem, goto, shift. Then that's it. If you don't go and learn those DOS commands related to the network, you won't understand the issue you mentioned about hackers using them for attacks.
|
|
2004-5-23 00:00 |
|