2023年7月3日发(作者:)
WindowsMSDOS的批处理⽂件命令Windows provides different system management modes like interactive and batch. Batch management mode is used likerunning scripts without or little user s提供了不同的系统管理模式,例如交互式和批处理。 批处理管理模式的使⽤类似于运⾏脚本,⽽⽆需⽤户交互或⽤户交互很少。批处理⽂件和扩展名 (Batch File and Extension)Batch files are text files which contains MSDOS and Windows commands and tools. Batch files generally uses bat or other extensions can be used as long as they will run as batch file with .We can run a batch filewithout extension or different extension with . In this example we will run a batch file named 批处理⽂件是包含MSDOS和Windows命令和⼯具的⽂本⽂件。 批处理⽂件⼀般采⽤bat或cmd 其他扩展可以,只要他们将运⾏与批处理⽂件中使⽤ 。我们可以运⾏不带扩展名或不同的扩展名与批处理⽂件 。 在此⽰例中,我们将运⾏⼀个名为的批处理⽂件。$ OC –关联⽂件类型 (ASSOC – Associate File Type)We can use ASSOC command in order to find a file type and detailed explanation with this command. We will provide theextension like .txt into the ASSOC command like below.我们可以使⽤ASSOC命令来查找⽂件类型和此命令的详细说明。 我们将在以下的ASSOC命令中提供.txt之类的扩展名。ASSOC ".exe"ASSOC – Associate File TypeASSOC –关联⽂件类型As we can see from output that .exe extension is associated with executable file .从输出中可以看到, .exe扩展名与可执⾏⽂件相关联。If we do not provide a parameter ASSOC will list all existing associations with related extensions.如果我们不提供参数,则ASSOC将列出所有具有相关扩展名的现有关联。ASSOCATTRIB-列表⽂件属性 (ATTRIB- List File Attributes)ATTRIB command is used to list, display and change file attributes about files, folders and 命令⽤于列出,显⽰和更改有关⽂件,⽂件夹和⽬录的⽂件属性。列表属性 (List Attributes)We can list given file or folder attributes like below.我们可以像下⾯列出给定的⽂件或⽂件夹属性。attrib t Attributes列表属性更改为只读(Change To Read Only)We can change the file attribute to read only which will made given file uneditable.我们可以将⽂件属性更改为只读,这会使给定的⽂件不可编辑。attrib +r 隐藏 (Make Hidden)If we want to make to hidden the file we will use +ah option. This will made file hidden from regular user files and folders.如果我们想隐藏⽂件,我们将使⽤+ah选项。 这将使⽂件从常规⽤户⽂件和⽂件夹中隐藏。attrib +ah 删除只读属性 (Remove Read Only Attribute)After setting some attributed we can remote these attributes later. We will use - sign to remove specified attribute. In thisexample we will remove read only attribute with the -r option like below.设置⼀些属性后,我们可以在以后远程访问这些属性。 我们将使⽤-符号删除指定的属性。 在此⽰例中,我们将使⽤-r选项删除只读属性,如下所⽰。attrib -r –更改当前⼯作⽬录 (CD – Change Current Working Directory)CD will provide very useful feature where we can change given working directory. We can also provide multi level paths 将提供⾮常有⽤的功能,我们可以在其中更改给定的⼯作⽬录。 我们还可以提供多级更改路径。更改为给定的⼦⽬录 (Change To Given Child Directory)We will start by changing given child directory. We will first use DIR to list directories.我们将从更改给定的⼦⽬录开始。 我们将⾸先使⽤DIR列出⽬录。cd UsersChange To Given Child Directory更改为给定的⼦⽬录转到⽗⽬录(Change To Parent Directory)We can use .. as specify parent directory. We can go upper level directory or parent directory with the following command.我们可以使⽤..作为指定⽗⽬录。 我们可以使⽤以下命令进⼊上⼀级⽬录或上级⽬录。cd ..更改驱动器或分区 (Change Drive or Partition)We can also change the current partition. We will change to the drive :d in this example.我们还可以更改当前分区。 在本⽰例中,我们将更改为drive :d 。cd d:CHKDSK –检查磁盘和⽂件系统⼀致性 (CHKDSK – Check Disk and File SystemConsistency)CHKDSK command can be used to check and repair disk and file systems. We can simply use it like 命令可⽤于检查和修复磁盘和⽂件系统。 我们可以像下⾯这样简单地使⽤它。chkdskCHOICE – Provide List Of Options选择–提供选项列表If we need to get input from the user with provided choice we can use CHOICE command like below. We will provide Yes orNo like below.如果需要使⽤提供的选项从⽤户那⾥获取输⼊,则可以使⽤如下所⽰的CHOICE命令。 我们将提供“是”或“否”,如下所⽰。ECHO You want tea?CHOISE /c YN /m "Yes or No"CLS-清除屏幕 (CLS- Clear The Screen)After some work and operation there will be a lot of option on the console or screen. We can clean this console or screenwith the CLS command.经过⼀些⼯作和操作后,控制台或屏幕上将有很多选项。 我们可以使⽤CLS命令清理此控制台或屏幕。CLSCMD –调⽤新命令提⽰符 (CMD – Invoke New Command Prompt)If we want to create new or child command prompt we can use CMD which will call application.如果要创建新命令或⼦命令提⽰符,可以使⽤CMD来调⽤应⽤程序。CMDCOMP –⽐较两个⽂件⼤⼩ (COMP – Compare Two Files Sizes)If we have some some files and we want to compare their sizes we can use COMP command. We will provide two paramersthose will be the file names. In this example we will compare files named and 如果我们有⼀些⽂件,并且想⽐较它们的⼤⼩,可以使⽤COMP命令。 我们将提供两个参数,它们将是⽂件名。 在此⽰例中,我们将⽐较名为和⽂件COMP 转换–转换⽂件系统类型 (CONVERT – Convert File System Type)This is a bit low level command where we can convert file system of the given partition. In this example we will convertpartition D: .这是⼀个有点低级的命令,我们可以在其中转换给定分区的⽂件系统。 在此⽰例中,我们将转换分区D:CONVERT D:COPY –复制⽂件 (COPY – Copy Files)We can copy given file to the destination with the COPY command. In this example we will copy file to the D: partition.我们可以使⽤COPY命令将给定⽂件复制到⽬标位置。 在此⽰例中,我们将⽂件复制到D:分区。COPY c: d:DATE –显⽰当前⽇期 (DATE – Display Current Date)We can use %DATE% variable which holds the current date. We will print to the console with the echo command.我们可以使⽤%DATE%变量来保存当前⽇期。 我们将使⽤echo命令打印到控制台。echo %DATE%DATE – Display Current DateDATE –显⽰当前⽇期DEL –删除⽂件(DEL – Delete Files)We can delete files with the DEL command. We will provide the name of the file we want to delete.我们可以使⽤DEL命令删除⽂件。 我们将提供我们要删除的⽂件的名称。了解更多信息Windows操作系统中的命令⾏和命令提⽰符是什么?删除给定⽂件 (Delete Given File)We will delete file named 我们将删除名为⽂件DEL 删除给定扩展名 (Delete Given Extension)We can also delete for specific extension. For example we can delete text files those generally have .txt extension with thefollowing command.我们也可以删除特定扩展名。 例如,我们可以使⽤以下命令删除扩展名通常为.txt⽂本⽂件。DEL *.txt删除⽂件前询问 (Ask Before Delete File)If we will delete in bulk confirmation will help us. We can use /p option which will enable confirmation before each filedeletion.如果我们将批量删除,确认将对我们有帮助。 我们可以使⽤/p选项,该选项将在每个⽂件删除之前启⽤确认。DEL /p *.txtDIR –列出⽂件和⽂件夹 (DIR – List File and Folders)We can list current working and given directory files and folders with the DIR command like below.我们可以使⽤DIR命令列出当前⼯作⽬录和给定⽬录⽂件和⽂件夹,如下所⽰。列出所有⽂件和⽂件夹 (List All Files and Folders)We can use DIR without any option to list all files and folders for the current working directory我们可以不带任何选项使⽤DIR列出当前⼯作⽬录的所有⽂件和⽂件夹DIRList All Files and Folders列出所有⽂件和⽂件夹列出隐藏的⽂件和⽂件夹(List Hidden Files and Folders)By default hidden files and folders do not listed. But we can list hidden files and folders with the /ah option like below.默认情况下,未列出隐藏的⽂件和⽂件夹。 但是我们可以使⽤/ah选项列出隐藏的⽂件和⽂件夹,如下所⽰。DIR /ahList Hidden Files and Folders列出隐藏的⽂件和⽂件夹列出特定的扩展⽂件(List Specific Extension Files)We can list specific extension by providing the extension to the DIR command. In this example we will list extension with*.php我们可以通过提供DIR命令的扩展名来列出特定的扩展名。 在此⽰例中,我们将列出带有*.php扩展名dir "*.php"DISKPART –显⽰和更改磁盘分区和属性 (DISKPART – Show and Change DiskPartition and Properties)We can use DISKPART command in order to list, display and change disk partition properties.我们可以使⽤DISKPART命令来列出,显⽰和更改磁盘分区属性。DISKPARTDRIVERQUERY –列出驱动程序和属性(DRIVERQUERY – List Drivers and Properties)We can use DRIVERQUERY in order to list installed device drivers and related properties with dates.我们可以使⽤DRIVERQUERY来列出已安装的设备驱动程序和相关属性以及⽇期。DRIVERQUERYDRIVERQUERY – List Drivers and PropertiesDRIVERQUERY –列出驱动程序和属性ECHO –打印到控制台(ECHO – Print To The Console)ECHO command is used to print to the console or standard output. We can also use this command in order to printenvironment variables or given 命令⽤于打印到控制台或标准输出。 我们也可以使⽤此命令来打印环境变量或给定的字符串。打印给定的字符串 (Print Given String)We will print given string which is "Hello World" in this case.在这种情况下,我们将打印给定的字符串"Hello World" 。ECHO "Hello World"打印环境变量 (Print Environment Variable)We can print given environment variable like %DATE% in this case在这种情况下,我们可以打印给定的环境变量,例如%DATE%echo %DATE%退出–终⽌并退出控制台 (EXIT – Terminate and Exit From Console)We can use EXIT in order to terminate current console and exit. This will also end current script too.我们可以使⽤EXIT来终⽌当前控制台并退出。 这也将结束当前脚本。EXITFC –区分两个⽂件 (FC – Diff Two Files)We can compare two files and print differencies with the FC command. We will provide two files named and in thisexample.我们可以⽐较两个⽂件并使⽤FC命令打印差异。 在此⽰例中,我们将提供两个名为和⽂件。FC 查找–在⽂件中搜索给定的字符串 (FIND – Search Given String In A File)We can use FIND command to search for given string in a given file. In this example we will search for test in file named .我们可以使⽤FIND命令在给定⽂件中搜索给定字符串。 在此⽰例中,我们将在名为⽂件中搜索test 。FIND "test" 格式-更改⽂件系统 (FORMAT – Change File System)Another command to change File System is FORMAT command. We will also provide the partition we want to format.更改⽂件系统的另⼀个命令是FORMAT命令。 我们还将提供要格式化的分区。FORMAT F:帮助–显⽰帮助信息 (HELP – Display Help Information)While using batch commands we may need to get help for general or specific command. We can use HELP command whichwill display available commands provided by MSDOS.使⽤批处理命令时,我们可能需要获得常规或特定命令的帮助。 我们可以使⽤HELP命令,它将显⽰MSDOS提供的可⽤命令。了解更多信息如何以Windows的不同⽅式从命令⾏启动应⽤程序?列出所有命令 (List All Command)Without any option we can list all commands provided by MSDOS with HELP command like below.没有任何选择,我们可以列出MSDOS提供的所有命令以及如下的HELP命令。HELPList All Command列出所有命令帮助特定命令(Help For Specific Command)We can get detailed information about a MSDOS command by providing the command after HELP. In this example we willlist information about DIR command.通过在HELP之后提供命令,我们可以获得有关MSDOS命令的详细信息。 在此⽰例中,我们将列出有关DIR命令的信息。HELP dirHelp For Specific Command帮助特定命令IPCONFIG –列出⽹络配置,如IP地址(IPCONFIG – List Network Configuration Like IPAddress)IPCONFIG will list information about the current system network interfaces and IP IG将列出有关当前系统⽹络接⼝和IP配置的信息。IPCONFIGIPCONFIG – List Network Configuration Like IP AddressIPCONFIG –列出⽹络配置,如IP地址标签–添加,设置或删除磁盘标签(LABEL – Add, Set or Remove Disk Labels)Disks are labeled for easy of management. We can use LABEL command in order to change or remove disk labels.磁盘被标记为易于管理。 我们可以使⽤LABEL命令来更改或删除磁盘标签。LABEL D:LABEL – Add, Set or Remove Disk Labels标签–添加,设置或删除磁盘标签MD –创建新⽬录(MD – Create New Directory)We can use MD command in order to create new directory or folder. In this example we will create a folder named BACKUP.我们可以使⽤MD命令来创建新⽬录或⽂件夹。 在此⽰例中,我们将创建⼀个名为BACKUP的⽂件夹。MD BACKUP更多–阅读⽂件内容 (MORE – Read File Contents)We can read a file content with the MORE command. Especially text files can be printed from command line. We will alsoprovide the file name to this command.我们可以使⽤MORE命令读取⽂件内容。 特别是⽂本⽂件可以从命令⾏打印。 我们还将提供此命令的⽂件名。MORE 移动–移动⽂件和⽂件夹 (MOVE – Move Files and Folders)We can use MOVE command in order to move files and folders. This command can be also used to rename files and folders.我们可以使⽤MOVE命令来移动⽂件和⽂件夹。 此命令还可⽤于重命名⽂件和⽂件夹。MOVE c: d: –管理Windows⽹络服务 (NET – Manage Windows Network Services)Windows operating system provides a lot of network related options for their operating system and services. We can useNET command with the following s操作系统为其操作系统和服务提供了许多与⽹络相关的选项。 我们可以使⽤具有以下功能的NET命令。net accounts净账户net computer⽹络计算机net config⽹络配置net continue净继续net file⽹络⽂件net group⽹组net help⽹络帮助net name⽹名net pause净暂停net print净印刷net send净发送net session净会话net share净份额net start净启动net statistics净统计net stop净⽌损net time净时间net use净使⽤net view净视图PATH –显⽰路径变量 (PATH – Display Path Variable)PATH variable provides commands and applications to run. We can list these paths with the PATH 变量提供要运⾏的命令和应⽤程序。 我们可以使⽤PATH变量列出这些路径。echo %PATH%PATH – Display Path VariablePATH –显⽰路径变量暂停–停⽌当前正在运⾏的脚本(PAUSE – Stop Current Running Script)If we want to stop a script output we can use PAUSE command. This will stop script up to pressing a key for the console.如果要停⽌脚本输出,可以使⽤PAUSE命令。 这将停⽌脚本,直到按控制台的键为⽌。PAUSEPING –测试远程主机 (PING – Test Remote Hosts)PING command can be used to test remote system connectivity. We will also provide the IP address or host name of theremote system. It will send 4 time and ICMP package for 命令可⽤于测试远程系统连接。 我们还将提供远程系统的IP地址或主机名。 它将发送4时间和ICMP包进⾏测试。PING G – Test Remote HostsPING –测试远程主机RD –删除空⽬录(RD – Remove Empty Directories)We can use RD command in order to remove empty directory. This will not work for non-empty directories. We will removedirectory named ABC.我们可以使⽤RD命令来删除空⽬录。 这不适⽤于⾮空⽬录。 我们将删除名为ABC⽬录。RD ABCREM –在批处理⽂件中添加注释 (REM – Add Comment To The Batch File)We may need to put some comments about the script file. We will use REM in order to add comments. All lines starting withthe REM will interpreted as comment.我们可能需要对脚本⽂件添加⼀些注释。 我们将使⽤REM来添加评论。 以REM开头的所有⾏将被解释为注释。REM This is a comment no command :)REN –重命名⽂件和⽬录 (REN – Rename File and Directories)We can rename files and directories with the REN command. We will provide current name and new name. In this examplewe will rename file to the 我们可以使⽤REN命令重命名⽂件和⽬录。 我们将提供当前名称和新名称。 在此⽰例中,我们将⽂件重命名为 –显⽰环境变量 (SET – Display Environment Variables)We can list current environment variables with the SET command.我们可以使⽤SET命令列出当前的环境变量。SETSET – Display Environment VariablesSET –显⽰环境变量关机–关闭系统(SHUTDOWN – Shutdown the System)We can shutdown the system with the SHUTDOWN command like below.我们可以使⽤SHUTDOWN命令关闭系统,如下所⽰。SHUTDOWNSORT –对⽂件内容进⾏排序 (SORT – Sort Content Of A File)We can sort given file content and print to the console with the SORT command like below. In this example we will sort andprint file named 我们可以对给定的⽂件内容进⾏排序,并使⽤SORT命令将其打印到控制台,如下所⽰。 在此⽰例中,我们将排序并打印名为⽂件SORT 开始–启动新程序 (START – Start New Program)We can use START command by providing and exe or a batch file to start. In this example we will start the applicationnamed 我们可以通过提供START命令和exe或批处理⽂件来启动。 在此⽰例中,我们将启动名为的应⽤程序START TEMINFO –显⽰计算机和操作系统信息 (SYSTEMINFO – Display Computer andOperating System Information)We can use SYSTEMINFO in order to list and display computer, operating system and software information.我们可以使⽤SYSTEMINFO来列出和显⽰计算机,操作系统和软件信息。SYSTEMINFOSYSTEMINFO – Display Computer and Operating System InformationSYSTEMINFO –显⽰计算机和操作系统信息任务杀死–杀死任务和过程 (TASKKILL – Kill Task and Process)Processes can be killed in different ways. We can use TASKKILL command in order to end given process. In this example wewill ill task or process named 可以⽤不同的⽅式杀死进程。 我们可以使⽤TASKKILL命令来结束给定的过程。 在此⽰例中,我们将使名为任务或进程KKILL /im 任务列表–列出当前任务或过程 (TASKLIST – List Current Tasks or Processes)We can list currently running tasks and processes with the TASKLIST command.我们可以使⽤TASKLIST命令列出当前正在运⾏的任务和流程。TASKLISTTASKLIST – List Current Tasks or Processes任务列表–列出当前任务或过程TIME –显⽰或设置当前时间(TIME – Display or Set Current Time)We can use TIME command in order to display or set current time of the system. We will use %TIME% variable like below.我们可以使⽤TIME命令来显⽰或设置系统的当前时间。 我们将使⽤%TIME%变量,如下所⽰。echo %TIME%TIME – Display or Set Current TimeTIME –显⽰或设置当前时间标题-设置MSDOS控制台的标题(TITLE – Set Title Of MSDOS Console)We can set the title of the currently running MSDOS console with the TITLE command. In this example we will set theconsole title as MYCONSOLE我们可以使⽤TITLE命令设置当前正在运⾏的MSDOS控制台的TITLE 。 在此⽰例中,我们将控制台标题设置为MYCONSOLETITLE MYCONSOLETREE –将⼦⽬录显⽰为树 (TREE – Display Subdirectories As Tree)We can list current directory child or subdirectories with the TREE command. It will provide very useful output forinvestigating folder hierarchy.我们可以使⽤TREE命令列出当前⽬录的⼦⽬录或⼦⽬录。 这将为调查⽂件夹层次结构提供⾮常有⽤的输出。TREETREE – Display Subdirectories As TreeTREE –将⼦⽬录显⽰为树VER –显⽰Windows或MSDOS版本(VER – Display Windows or MSDOS Version)Windows operating systems and MSDOS have different versions. We can display current operating system and MSDOSversion with the VERcommand like s操作系统和MSDOS具有不同的版本。 我们可以使⽤VER命令显⽰当前的操作系统和MSDOS版本,如下所⽰。VERVER – Display Windows or MSDOS VersionVER –显⽰Windows或MSDOS版本VOL –显⽰⾳量标签(VOL – Display Volume Label)We can displat current volume label with the VOL command.我们可以使⽤VOL命令显⽰当前的⾳量标签。VOLXCOPY –复制⽂件和⽂件夹 (XCOPY – Copy Files and Folders)XCOPY command can be used to copy files and folders. We will provide the source and destination files and folders. In thisexample file to the PY命令可⽤于复制⽂件和⽂件夹。 我们将提供源和⽬标⽂件和⽂件夹。 在此⽰例⽂件到PY 了解更多信息Windows操作系统中的命令⾏和命令提⽰符是什么?
发布者:admin,转转请注明出处:http://www.yc00.com/web/1688382513a129665.html
评论列表(0条)