批处理中的所有命令是什么意思和做什么? [英] What do all commands in batch mean and do?

查看:187
本文介绍了批处理中的所有命令是什么意思和做什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如nul,local,localhost,%〜d0,setlocal,for命令? %?一条路径? REM?分类? Delims?做? Delims?平?本地ping? Arp?跟踪? tracert? tc,netem? rm? ()?光盘? set / p,set / f,md?我在许多批处理文件中看到这个代码,但从来没有得到他们做什么,意思和他们是什么。我几天前第一次有一台电脑,即使电脑的老我想尽可能学习。



现在我只知道一些基本命令,如@echo,set,set / p,start,goto和一些酷的技巧,如无限循环,使一个基本的杂货店程序,改变颜色等。



还有我可以用批处理。请帮助!

解决方案

首先要记住的是操作计算机的方法。



Windows支持两种菜单类型:弹出菜单和下拉菜单。第三种类型是下拉,Windows不支持。弹出 - 您可以单击文件菜单,然后单击打开菜单项。向下拉 - 向下拖动文件菜单上的鼠标按钮,向下拖动到打开,然后鼠标左键向上。



获取帮助:鼠标光标放在文件菜单上并下拉,然后点击打开

b

有关一般帮助。在命令提示符中键入帮助。对于列出的每个命令 help< command> (例如 help dir )或命令> /?(例如 dir /?)。



有些命令有子命令。例如 schtasks / create /?



NET 命令的帮助是不寻常的。键入 net use /?是一个简短的帮助。键入 net help use 以获得完整的帮助。这同样适用于根 - net /?也是简短的帮助,使用 net help






标点符号

 &在一行上分隔命令。 

&&只有在上一个命令的错误等级为0时才执行此命令。

|| (以上不使用)只有在上一个命令的
errorlevel不为0时才执行此命令

>输出到文件

>>将输出附加到文件

<从文件输入

2>将指令错误输出重定向到指定的文件。 (0是StdInput,1是StdOutput,2是StdError)

2>& 1将命令错误输出重定向到与命令输出相同的位置。

|输出一个命令到另一个命令的输入

^如果需要传递
到程序

参数其中空格必须用引号括起

+用于复制到并置文件EG copy file1 + file2 newfile

,用于复制以指示缺少的参数。
修改日期EG copy / b file1 ,,

%variablename%a内置或用户设置环境变量

!variablename!用户设置环境变量展开执行
时间,使用SelLocal EnableDelayedExpansion命令转换

%< number>(%1)传递给批处理文件的第n个命令行参数%0
是批处理文件的名称。

%*(%*)整个命令行

%CMDCMDLINE% - 扩展到调用
命令处理器的原始命令行/?)。

%< a letter>或%%< a letter>(%A或%% A)for循环中的变量。
在命令提示符处单个%符号,在批处理文件中双%号。

\\(\\servername\sharename\folder\file.ext)通过UNC命名访问文件和文件夹。

:(win.ini:streamname)访问一个替代的蒸汽。还将驱动器与路径的其余部分分离。

。 (win.ini)文件路径中的LAST点将名称与扩展名

分隔开。 (dir .\ * .txt)当前目录

..(cd ..)父目录


\\?\ \\?\c:\windows \win.ini)当文件路径带有前缀\\?\文件名检查已关闭时。




< > :/ \ |保留字符。不能用于文件名



保留的名称,它们指的是设备,例如

copy文件名con

将文件复制到控制台窗口

CON,PRN,AUX,NUL,COM1,COM2,COM3,COM4,

COM5,COM6,COM7,COM8,COM9,LPT1,LPT2,

LPT3,LPT4,LPT5,LPT6,LPT7,LPT8和LPT9

CONIN $,CONOUT $ ,CONERR $

--------------------------------

最大路径长度260个字符
最大路径长度(\\?\)32,767个字符(大约 - 一些罕见字符使用2个字符的存储空间)
最大文件名长度255个字符






启动程序 b
$ b

有关所有三种方式,请参阅start /?和call /?帮助。



指定程序名称



  c:\windows\\\
otepad.exe

在批处理文件中,批处理将等待程序退出。当
键入时,命令提示符不等待图形化的
程序退出。



如果程序是批处理文件,



<$ h <> > p> startc:\windows\\\
otepad.exe

开始启动程序,不等待。控制台程序在新窗口中启动。使用/ b开关强制控制台程序进入同一个窗口,这否定了启动的主要目的。



启动使用Windows图形外壳 - 与键入WinKey + R (运行对话框)。尝试

 启动shell:缓存

$ b $



使用呼叫命令



调用用于启动批处理文件,并等待他们退出并继续当前批处理文件。








Ctrl + C 退出程序,控制台窗口。



对于其他编辑键类型 Doskey /?


For example nul, local, localhost, %~d0, setlocal, the for command? %? A path? REM? SORT? Delims? Do? Delims? Ping? Local ping? Arp? Trace? tracert? tc, netem? rm? ()? cd? set /p, set/f, md? I've seen this code in many batch files but never get what they do and mean and what they're for. I've just got a computer for the first time a few days ago, even if the computer's old I wanna learn as much as I can.

Right now i only know a few basic commands like @echo, set, set /p, start,goto, and a few cool tricks like infinite loops, make a basic grocery store program, change colors, etc.

And what else can I do with batch. Please help!

解决方案

First thing to remember its a way of operating a computer. It's the way we did it before WIMP (Windows, Icons, Mouse, Popup menus) became common.

Windows supports two menu types - Popup and Pull Down. The third type was Drop Down which Windows doesn't support. Popup - you would click File menu then click Open menu item. Pull Down - left mouse button down on file menu, drag down to Open then left mouse button up. Drop Down - place mouse cursor over file menu and it will drop down, then click open.

Getting Help

For general help. Type Help in the command prompt. For each command listed type help <command> (eg help dir) or <command> /? (eg dir /?).

Some commands have sub commands. For example schtasks /create /?.

The NET command's help is unusual. Typing net use /? is brief help. Type net help use for full help. The same applies at the root - net /? is also brief help, use net help.


Punctuation

&    seperates commands on a line.

&&    executes this command only if previous command's errorlevel is 0.

||    (not used above) executes this command only if previous command's 
errorlevel is NOT 0

>    output to a file

>>    append output to a file

<    input from a file

2> Redirects command error output to the file specified. (0 is StdInput, 1 is StdOutput, and 2 is StdError)

2>&1 Redirects command error output to the same location as command output. 

|    output of one command into the input of another command

^    escapes any of the above, including itself, if needed to be passed 
to a program

"    parameters with spaces must be enclosed in quotes

+ used with copy to concatinate files. E.G. copy file1+file2 newfile

, used with copy to indicate missing parameters. This updates the files 
modified date. E.G. copy /b file1,,

%variablename% a inbuilt or user set environmental variable

!variablename! a user set environmental variable expanded at execution 
time, turned with SelLocal EnableDelayedExpansion command

%<number> (%1) the nth command line parameter passed to a batch file. %0 
is the batchfile's name.

%* (%*) the entire command line.

%CMDCMDLINE% - expands to the original command line that invoked the
Command Processor (from set /?).

%<a letter> or %%<a letter> (%A or %%A) the variable in a for loop. 
Single % sign at command prompt and double % sign in a batch file.

\\ (\\servername\sharename\folder\file.ext) access files and folders via UNC naming.

: (win.ini:streamname) accesses an alternative steam. Also separates drive from rest of path.

. (win.ini) the LAST dot in a file path separates the name from extension

. (dir .\*.txt) the current directory

.. (cd ..) the parent directory


\\?\ (\\?\c:\windows\win.ini) When a file path is prefixed with \\?\ filename checks are turned off. 




< > : " / \ | Reserved characters. May not be used in filenames.



Reserved names. These refer to devices eg, 

copy filename con 

which copies a file to the console window.

CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, 

COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, 

LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9

CONIN$, CONOUT$, CONERR$

--------------------------------

Maximum path length              260 characters
Maximum path length (\\?\)      32,767 characters (approx - some rare characters use 2 characters of storage)
Maximum filename length        255 characters


Starting a Program

See start /? and call /? for help on all three ways.

Specify a program name

c:\windows\notepad.exe

In a batch file the batch will wait for the program to exit. When typed the command prompt does not wait for graphical programs to exit.

If the program is a batch file control is transferred and the rest of the calling batch file is not executed.

Use Start command

start "" c:\windows\notepad.exe

Start starts a program and does not wait. Console programs start in a new window. Using the /b switch forces console programs into the same window, which negates the main purpose of Start.

Start uses the Windows graphical shell - same as typing in WinKey + R (Run dialog). Try

start shell:cache

Also note the first set of quotes, if any, MUST be the window title.

Use Call command

Call is used to start batch files and wait for them to exit and continue the current batch file.


Keys

Ctrl + C exits a program without exiting the console window.

For other editing keys type Doskey /?

这篇关于批处理中的所有命令是什么意思和做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆