批处理命令大全(合集命令)

合集下载

批处理命令大全

批处理命令大全

会分析my中的每一行,忽略以分号打头的那些行,将每 行中的第二个和第三个符号传递给for程序体;用逗号和/ 或空格定界符号。
请注意,这个for程序体的语句引用%i来取得第二个符号, 引用%j来取得第三个符号,引用%k来取得第三个符号后 的所有剩余符号。对于带有空格的文
件名,您需要用双引号将文件名括起来。为了用这种方 式来使用双引号,您还需要使用usebackq选项,否则,双 引号会被理解成是用作定义某个要分析
C::>SHIFT.BAT12345678
91011 123456789 2345678910
34567891011 以上就是基于WIN2000下的9个批处理命令。 第二
部分:特殊的符号与批处理
在命令行下有些符号是不允许使用的但有些符号却有着特殊的意 义。 1、符号(@) @在批处理中的意思是关闭当前行
的字符串的。
%i专门在for语句中得到说明,%j和%k是通过tokens=选项 专门得到说明的。您可以通过tokens=一行指定最多26个
符号,只要不试图说明一个高于字母'z'或'Z'的变数。请记 住,FOR变量名分大小写,是通用的;而且,同时不能有 52个以上都在使用中。 您还
可以在相邻字符串上使用FOR/F分析逻辑;方法是,用单 引号将括号之间的括起来。这样,该字符串会被当作一 个檔中的一个单一
51.txt 2003-03-1211:430aierrorlog.txt 2003-03-3000:3530,571202.108.t
xt 5个文件18,630,070字节 0个目录1,191,542,784可用字节 >将命令执行的结果覆盖了原始的檔内容。 在传递给
控制台的时候程序将不会有任何回显(注意:这里的回 显跟echooff关掉的回显不是同一概念。Echooff关掉的是 输入命令的回显,这里的回显是

批处理常用命令及用法大全

批处理常用命令及用法大全

批處理常用命令及用法大全閱讀本文需要一定的dos基礎概念,象:盤符、文件、目錄(文件夾)、子目錄、根目錄、當前目錄每個命令的完整說明請加/? 參數參考微軟的幫助文檔可以看到,在/? 幫助裏,"命令擴展名"一詞會經常出現"命令擴展名"是指相對於win98的dos版本而言,每個命令新增的功能命令測試環境win2000proSP4win98的命令功能太少,就不作研究了注:如果對某一命令還不是很熟悉,可以在命令行窗口下輸入:命令名/?的方式來獲得幫助。

例如:對dir命令的應用不熟悉,可以在命令行窗口下輸入:dir /?1 echo 和@回顯控制命令@關閉單行回顯echo off從下一行開始關閉回顯@echo off從本行開始關閉回顯。

一般批處理第一行都是這個echo on從下一行開始打開回顯echo顯示當前是echo off 狀態還是echo on 狀態echo.輸出一個"回車換行",一般就是指空白行echo hello world輸出hello world"關閉回顯"是指運行批處理文件時,不顯示文件裏的每條命令,只顯示運行結果批處理開始和結束時,系統都會自動打開回顯2 errorlevel程序返回碼echo %errorlevel%每個命令運行結束,可以用這個命令行格式查看返回碼用於判斷剛才的命令是否執行成功默認值為0,一般命令執行出錯會設errorlevel 為13 dir顯示目錄中的文件和子目錄列表dir顯示當前目錄中的文件和子目錄dir /a顯示當前目錄中的文件和子目錄,包括隱藏文件和系統文件dir c: /a:d顯示 C 盤當前目錄中的目錄dir c:\ /a:-d顯示 C 盤根目錄中的文件dir d:\mp3 /b/p逐屏顯示d:\mp3 目錄裏的文件,只顯示文件名,不顯示時間和大小dir *.exe /s顯示當前目錄和子目錄裏所有的.exe文件其中* 是通配符,代表所有的文件名,還一個通配符? 代表一個任意字母或漢字如c*.* 代表以c 開頭的所有文件?.exe 代表所有文件名是一個字母的.exe文件如果指定的目錄或文件不存在,將返回errorlevel 為1;每個文件夾的dir 輸出都會有2個子目錄. 和... 代表當前目錄.. 代表當前目錄的上級目錄dir .顯示當前目錄中的文件和子目錄dir ..顯示當前目錄的上級目錄中的文件和子目錄其它參數可參考dir /?4 cd更改當前目錄cd mp3進入當前目錄中的mp3 目錄cd ..進入當前目錄中的上級目錄cd\進入根目錄cd顯示當前目錄cd /d d:\mp3可以同時更改盤符和目錄cd "Documents and Settings"\All users文件名帶空格,路徑前需要加上引號!!如果更改到的目錄不存在,則出錯返回errorlevel=15 md創建目錄mdabc在當前目錄裏建立子目錄abcmd d:\a\b\c如果d:\a 不存在,將會自動創建6 rd刪除目錄rd abc刪除當前目錄裏的abc 子目錄,要求為空目錄rd /s/q d:\temp刪除d:\temp 文件夾及其子文件夾和文件,不需要按Y確認7 del刪除文件deld:\test.txt刪除指定文件,不能是隱藏、系統、只讀文件del *.*刪除當前目錄裏的所有文件,不包括隱藏、系統、只讀文件,要求按Y確認del /q/a/f d:\temp\*.*刪除d:\temp 文件夾裏面的所有文件,包括隱藏、只讀、系統文件,不包括子目錄del /q/a/f/s d:\temp\*.*刪除d:\temp 及子文件夾裏面的所有文件,包括隱藏、只讀、系統文件,不包括子目錄8 ren文件重命名ren 1.txt 2.bak把 1.txt 更名為2.bakren *.txt *.ini把當前目錄裏所有.txt文件改成.ini文件ren d:\temp tmp支持對文件夾的重命名9 cls清屏10 type顯示文件內容type c:\boot.ini顯示指定文件的內容,程序文件一般會顯示亂碼type *.txt顯示當前目錄裏所有.txt文件的內容11 copy拷貝文件copy c:\test.txt d:\複制c:\test.txt 文件到d:\copy c:\test.txt d:\test.bak複制c:\test.txt 文件到d:\ ,並重命名為test.bakcopy c:\*.*複制c:\ 所有文件到當前目錄,不包括隱藏文件和系統文件不指定目標路徑,則默認目標路徑為當前目錄copy con test.txt從屏幕上等待輸入,按Ctrl+Z 結束輸入,輸入內容存為test.txt文件con代表屏幕,prn代表打印機,nul代表空設備copy 1.txt + 2.txt 3.txt合並 1.txt 和 2.txt 的內容,保存為3.txt 文件如果不指定3.txt ,則保存到1.txtcopy test.txt +複制文件到自己,實際上是修改了文件日期12 title設置cmd窗口的標題title 新標題可以看到cmd窗口的標題欄變了13 ver顯示系統版本14 label 和vol設置卷標vol顯示卷標label顯示卷標,同時提示輸入新卷標label c:system設置C盤的卷標為system15 pause暫停命令運行該命令時,將顯示下面的消息:請按任意鍵繼續. . .一般用於看清楚屏幕上顯示的內容16 rem 和::注釋命令注釋行不執行操作17 date 和time日期和時間date顯示當前日期,並提示輸入新日期,按"回車"略過輸入date/t只顯示當前日期,不提示輸入新日期time顯示當前時間,並提示輸入新時間,按"回車"略過輸入time/t只顯示當前時間,不提示輸入新時間18 goto 和:跳轉命令:label行首為:表示該行是標簽行,標簽行不執行操作goto label跳轉到指定的標簽那一行19 find (外部命令)查找命令find "abc" c:\test.txt在c:\test.txt 文件裏查找含abc 字符串的行如果找不到,將設errorlevel 返回碼為1find /i "abc" c:\test.txt 查找含abc 的行,忽略大小寫find /c "abc" c:\test.txt顯示含abc 的行的行數20 more (外部命令)逐屏顯示more c:\test.txt逐屏顯示c:\test.txt 的文件內容21 tree顯示目錄結構tree d:\顯示D盤的文件目錄結構22 &順序執行多條命令,而不管命令是否執行成功c: & cd\ & dir /w相當於把下面3行命令寫到1行去了c:cd\dir /w23 &&順序執行多條命令,當碰到執行出錯的命令後將不執行後面的命令f: && cd\ && dir >c:\test.txt注意如果f盤不存在,那麼後面2條命令將不會執行find "ok" c:\test.txt && echo 成功如果找到了"ok"字樣,就顯示"成功",找不到就不顯示24 ||順序執行多條命令,當碰到執行正確的命令後將不執行後面的命令find "ok" c:\test.txt || echo 不成功如果找不到"ok"字樣,就顯示"不成功",找到了就不顯示25 |管道命令前一個命令的執行結果輸出到後一個命令dir *.* /s/a | find /c ".exe"管道命令表示先執行dir 命令,對其輸出的結果執行後面的find 命令該命令行結果:輸出當前文件夾及所有子文件夾裏的.exe文件的個數type c:\test.txt|more這個和more c:\test.txt 的效果是一樣的26 > 和>>輸出重定向命令> 清除文件中原有的內容後再寫入>> 追加內容到文件末尾,而不會清除原有的內容主要將本來顯示在屏幕上的內容輸出到指定文件中指定文件如果不存在,則自動生成該文件echo hello world>c:\test.txt生成c:\test.txt文件,內容為hello world 這個格式在批處理文件裏用得很多,可以生成.reg .bat .vbs 等臨時文件type c:\test.txt >prn 屏幕上不顯示文件內容,轉向輸出到打印機echo hello world>con在屏幕上顯示hello world,實際上所有輸出都是默認>con 的copy c:\test.txt f: >nul拷貝文件,並且不顯示"文件複制成功"的提示信息,但如果f盤不存在,還是會顯示出錯信息copy c:\test.txt f: >nul 2>nul不顯示"文件複制成功"的提示信息,並且f盤不存在的話,也不顯示錯誤提示信息echo ^^W ^> ^W>c:\test.txt生成的文件內容為^W > W^ 和> 是控制命令,要把它們輸出到文件,必須在前面加個^ 符號27 <從文件中獲得輸入信息,而不是從屏幕上一般用於date time label 等需要等待輸入的命令@echo offecho 2005-05-01>temp.txtdate <temp.txtdel temp.txt這樣就可以不等待輸入直接修改當前日期28 %0 %1 %2 %3 %4 %5 %6 %7 %8 %9 %*命令行傳遞給批處理的參數%0 批處理文件本身%1 第一個參數%9 第九個參數%* 從第一個參數開始的所有參數在C盤根目錄新建test.bat,內容如下:@echo offecho %0echo %1echo %2echo %*運行cmd,輸入c:\test.bat "/a" /b /c /d可以看出每個參數的含意修改test.bat內容如下@echo offecho %1echo %~1echo %0echo %~f0echo %~d0echo %~p0echo %~n0echo %~x0echo %~s0e cho %~a0echo %~t0echo %~z0再運行cmd,輸入c:\test.bat "/a" /b /c /d可以參照call/? 或for/? 看出每個參數的含意注意這裏可以對文件進行日期比較和大小比較echo load "%%1" "%%2">c:\test.txt生成的文件內容為load "%1" "%2"批處理文件裏,用這個格式把命令行參數輸出到文件31 set設置變量引用變量可在變量名前後加% ,即%變量名%set顯示目前所有可用的變量,包括系統變量和自定義的變量echo %SystemDrive%顯示系統盤盤符。

【珍藏】批处理常用指令([col...

【珍藏】批处理常用指令([col...

【珍藏】批处理常用指令([collection] common instructions forbatch processing)BAT command Daquan@ # single back offEcho off # began to close back from the next line@echo off # began to close back from the bank. This is the first line of general batch processingEcho on # began to open to the next lineEcho echo off is # displays the current state or echo state onEcho. # output a blank line, "enter"# (echo, echo; echo+ echo[echo] echo/ echo\)2 errorlevelEcho%errorlevel%Each command is run and you can view the return code in this command line formatThe default value is 0, and the general command error is set to errorlevel 13 dirDir # displays the current directory files and subdirectories.Dir /a # display in the current directory files and subdirectories, including hidden and system filesDir c: /a:d # display C in the current directory directory Dir c: /a:-d # display root directory C filesDir c:\ /b/p #/b displays only the file name, and the /p paging displayDir *.exe /s # display the current directory and all the subdirectories.Exe file4 CDCd\ # into the root directoryCD # displays the current directoryCD /d d:\sdk # can also change the drive and directory5 MDMD d:\a\b\c # if d:\a does not exist, it will automatically create the intermediate directoryIf # command extensions are disabled, you need to type MKDIR \a\b\c.6 RdRd ABC # delete the current directory ABC directory, for empty directoryRd /s/q d:\temp # delete the d:\temp folder and subfolders and files, /q quiet mode7 delDel d:\test.txt # deletefile, cannot be hidden, and read-only file systemDel /q/a/f d:\temp\*.*Delete all files inside the d:\temp folder, including hidden, read-only, system files, not subdirectoriesDel /q/a/f/s d:\temp\*.*Delete all files in the d:\temp and subfolders, including hidden, read-only, system files, not subdirectories8 RenRen d:\temp TMP # support to rename folder9 CLSClear the screen10 typeDisplay file contentsType c:\boot.ini # displays the contents of the specified file, the program files usually garbledType *.txt # display all.Txt files in the current directory contents11 copyCopy fileCopy c:\test.txt d:\test.bakCopy the c:\test.txt file to d:\ and rename it to test.bakCopy con test.txtFrom the screen, wait for the input, press Ctrl+Z to end the input, and save the input as a test.txt fileCon stands for screen, PRN stands for printer, and nul stands for empty deviceCopy 1.txt + 2.txt 3.txtMerge the contents of 1.txt and 2.txt and save it as a 3.txt fileIf no 3.txt is specified, then save to 1.txtCopy test.txt +Copying files to themselves is actually modifying the file date12 titleSet the title of the CMD windowTitle New Title # CMD can see the title bar of the window changed.13 verDisplay system version14 label and VolSet the labelVol # display labelLabel # display label, also prompted the new labelLabel c:system # set C label for system15 pausePause command16 REM and::Comment commandThe comment line does not perform the operation17 date and timeDate and timeDate # displays the current date, and prompted a new input date, press "enter" skipDate/t # only displays the current date, not prompt the new dateTime # displays the current time, and prompt new input time, press "enter" skipTime/t # only display the current time, not prompted to enter a new time18 goto and:Jump commandLabel: the # said it is tag line, the tag line does not perform the operationGoto label # jump to the specified label that line19 find (external command)Find commandFind \ \ "abc\" c:\test.txtFind the line containing the ABC string in the c:\test.txt file If not found, the errorlevel return code is set to 1Find /i, "ABC", c:\test.txtFind rows containing ABC, ignore case"Find /c \" "abc\" c:\test.txtShows the number of rows containing ABC20 more (external command)Screen by screen displayMore c:\test.txt # by screen display c:\test.txt file content 21 treeDisplay directory structureTree d:\ # display D disk file directory structure22 &Execute multiple commands in sequence, regardless of whether the command succeeds23 & &Execute multiple commands in sequence, and do not execute the following command when the command that executes the error is encounteredFind "ok\" c:\test.txt & & echoIf the word "ok\" is found, it is shown "success" and cannot be found if it is not found24 ||Execute multiple commands in sequence, and do not execute the following command when the correct command is encounteredFind "ok\" c:\test.txt echo || unsuccessfulIf the word "ok\" is not found, it is shown "unsuccessful \" and is not displayed when it is found25 |Pipe commandDir /s/a find /c. * | \ ".Exe\"The pipe command indicates that the dir command is executed first, and the subsequent find command is executed for the output of the commandThe command line results: output the number of.Exe files in the current folder and all subfoldersType c:\test.txt|moreThis is the same effect as the more c:\test.txt26 > andOutput redirection command> purge the original contents of the file before writing themAppend content to the end of the file without removing the original contentThe main contents of the original display on the screen is output to the specified fileIf the specified file does not exist, the file is automatically generatedType c:\test.txt >prnThe file content is not displayed on the screen, and the output is turned to the printerEcho Hello world>conThe Hello world is displayed on the screen, and virtually all outputs are default >conCopy c:\test.txt f: >nulCopy files and do not display "copy success \" prompt information, but if the f disk does not exist, it will still display error messagesCopy, c:\test.txt, f:, >nul, 2>nulDo not display the prompt information for the successful copy of the file, and the error message is not displayed if the f disk does not existEcho ^^W ^W>c:\test.txt ^>The generated file content is ^W > W"^" and "> are control commands. To output them to a file, you must add a" ^ "sign in front< 27Get input information from the file, not from the screenGenerally used for date, time, label, etc., need to wait for the input command@echo offEcho 2005-05-01>temp.txtDate del temp.txtThis way you can wait for the input to change the current date directly28%0%1%2%3%4%5%6%7%8%9%The command line passes the parameters to the batch%0 batch file itself%1 first parameter%9 ninth parametersAll parameters% from the first parameterThe substitution of batch parameter (%n) has been enhanced. You can use the following syntax:%~1 - delete quotation marks [[]) to expand%1%~f1 - extends%1 to a fully qualified path name%~d1 - extends%1 to a drive letter only%~p1 - extends%1 to only one path%~n1 - extends%1 to only one file name%~x1 - extends%1 to only one file extension%~s1 - extended path refers to a short name%~a1 - extend%1 to file attributes%~t1 - extend the%1 to the date / time of the file%~z1 - extends%1 to the size of the file%~$PATH: 1 - finds the column in the directory of the PATH environment variable, and%1Expand to the first fully qualified name to find. If the environmentThe variable name is not defined, or the file has not been found. This key combination willExtended to empty stringCan be combined to obtain multiple results with revision:%~dp1 - extends%1 to drive letters and paths only%~nx1 - extends%1 to file names and extensions only%~dp$PATH:1 - find%1 in the directory that is listed in the PATHenvironment variable,And extend to the drive letter and path to find the first file.%~ftza1 - extend%1 to similar output lines like DIR.You can see the meaning of each parameter by referring to call/ or for/Echo, load \%%1\, \%%2\, >c:\test.txtThe generated file contents are load \%1\ '\%2\'"In a batch file, the command line arguments are output to the file in this format29 IfJudgement commandIf "%1\" /a\ "echo" ==\ the first parameter is the /aIf /i \ \%1\ 'equ \ /a\' echo, the first parameter is /a/i said the case insensitive, and equ = = is the same, other operators see if/?If exist c:\test.bat echo exists c:\test.bat fileIf, not, exist, c:\windowsEcho does not exist in the c:\windows folder)If, exist, c:\test.batEcho exists c:\test.bat(else)Echo does not exist, c:\test.bat)30 SETLOCAL and endlocalSet the command extension and postpone the extension of the environment variable"SETLOCAL ENABLEEXTENSIONS # "command extensions enable \ \"SETLOCAL DISABLEEXTENSIONS # disable command extensions \ \ ""SETLOCAL enabledelayedexpansion #启用”延缓环境变量扩充\”SETLOCAL disabledelayedexpansion #停用”延缓环境变量扩充\”ENDLOCAL #恢复到使用SETLOCAL语句以前的状态“命令扩展名”默认为启用“延缓环境变量扩充”默认为停用批处理结束系统会自动恢复默认值可以修改注册表以禁用”命令扩展名\”,详见cmd /?。

批处理Bat命令大全

批处理Bat命令大全

BAT命令大全批处理文件的内容为: 命令注释:@echo off不显示后续命令行及当前命令行dir c:\*.* >a.txt将c盘文件列表写入a.txtcall c:\ucdos\ucdos.bat调用ucdosecho 你好显示"你好"pause 暂停,等待按键继续rem 准备运行wps 注释:准备运行wpscd ucdos进入ucdos目录wps 运行wps等号不等号:@echo offset val=''pauseif %val% == '' echo 值为空if not %val% == '' echo 值不为空PAUSE::注释1 echo 和 @@ #关闭单行回显echo off #从下一行开始关闭回显@echo off #从本行开始关闭回显。

一般批处理第一行都是这个echo on #从下一行开始打开回显echo #显示当前是 echo off 状态还是 echo on 状态echo. #输出一个”回车换行”,空白行#(同echo, echo; echo+echo[ echo] echo/ echo\)2 errorlevelecho %errorlevel%每个命令运行结束,可以用这个命令行格式查看返回码默认值为0,一般命令执行出错会设 errorlevel 为13 dirdir #显示当前目录中的文件和子目录dir /a #显示当前目录中的文件和子目录,包括隐藏文件和系统文件dir c: /a:d #显示 C 盘当前目录中的目录dir c: /a:-d #显示 C 盘根目录中的文件dir c:\ /b/p #/b只显示文件名,/p分页显示dir *.exe /s #显示当前目录和子目录里所有的.exe文件附:/s包含当前目录和子目录,没有/s时为当前目录4 cdcd\ #进入根目录cd #显示当前目录cd /d d:\sdk #可以同时更改盘符和目录5 mdmd d:\a\b\c #如果 d:\a 不存在,将会自动创建中级目录#如果命令扩展名被停用,则需要键入mkdir \a\b\c。

批处理命令大全

批处理命令大全

的字符串的。 %i专门在for语句中得到说明,%j和%k是通过tokens=选项 专门得到说明的。您可以通过tokens=一行指定最多26个
符号,只要不试图说明一个高于字母'z'或'Z'的变数。请记 住,FOR变量名分大小写,是通用的;而且,同时不能有 52个以上都在使用中。 您还
可以在相邻字符串上使用FOR/F分析逻辑;方法是,用单 引号将括号之间的filenameset括起来。这样,该字符串会 被当作一个檔中的一个单一
程序执行完毕跳至标题exit处退出 gotoexit :exit Rem这里是程序的出口 2、IFstring1==string2c
ommand 检测当前变量的值做出判断 ECHOOFF IF%1==2gotono Echo变数相等! Gotoexit :no
echo变数不相等 gotoexit :exit 大家可以这样看效果C:>test.bat数字 3、IF[NOT]EXISTfi
部分:特殊的符号与批处理 在命令行下有些符号是不允许使用的但有些符号却有着特殊的意 义。 1、符号(@) @在批处理中的意思是关闭当前行
的回显。我们从上面知道用命令echooff可以关掉整个批 处理的命令回显但却不能不显示echooff这个命令。现在 我们在这个命令前加上@这样e
chooff这一命令就被@关闭了回显从而达到所有命令均不回 显得要求 2、符号(>) >的意思是传递并覆盖。他所起的作用是将运行后的回显结
D如果集中包含通配符,则指定与目录名匹配,而不与文 件名匹配。 /F从指定的文件中读取数据作为变量 eol=c-指一个行注释字符的结尾(就
一个) skip=n-指在檔开始时忽略的行数。 delims=xxx-指分隔符集。这个替换了空格和跳格键的默认分隔符 集。 tokens

批处理命令大全

批处理命令大全

批处理命令大全批处理命令大全.txt我自横刀向天笑,笑完我就去睡觉。

你的手机比话费还便宜。

路漫漫其修远兮,不如我们打的吧。

hh.exe ntcmds.chm::/for.htm后台运行,文件名为X.vbsset ws=wscript.createobject("wscript.shell")ws.run "adsf.bat /start",0net config server /autodisconnect:1编辑批处理命令 any.bat内容 net session /delete /y1. gpedit.msc-----组策略2. sndrec32-------录音机3. Nslookup-------IP地址侦测器4. explorer-------打开资源管理器5. logoff---------注销命令6. tsshutdn-------60秒倒计时关机命令7. lusrmgr.msc----本机用户和组8. services.msc---本地服务设置9. oobe/msoobe /a----检查XP是否激活10. notepad--------打开记事本11. cleanmgr-------垃圾整理12. net start messenger----开始信使服务13. compmgmt.msc---计算机管理14. net stop messenger-----停止信使服务15. conf-----------启动netmeeting16. dvdplay--------DVD播放器17. charmap--------启动字符映射表18. diskmgmt.msc---磁盘管理实用程序19. calc-----------启动计算器20. dfrg.msc-------磁盘碎片整理程序21. chkdsk.exe-----Chkdsk磁盘检查22. devmgmt.msc--- 设备管理器23. regsvr32 /u *.dll----停止dll文件运行24. drwtsn32------ 系统医生25. rononce -p ----15秒关机26. dxdiag---------检查DirectX信息27. regedt32-------注册表编辑器28. Msconfig.exe---系统配置实用程序29. rsop.msc-------组策略结果集30. mem.exe--------显示内存使用情况31. regedit.exe----注册表32. winchat--------XP自带局域网聊天33. progman--------程序管理器34. winmsd---------系统信息35. perfmon.msc----计算机性能监测程序36. winver---------检查Windows版本37. sfc /scannow-----扫描错误并复原38. taskmgr-----任务管理器(2000,xp,200339. winver---------检查Windows版本40. wmimgmt.msc----打开windows管理体系结构(WMI)41. wupdmgr--------windows更新程序42. wscript--------windows脚本宿主设置43. write----------写字板44. winmsd---------系统信息45. wiaacmgr-------扫描仪和照相机向导46. winchat--------XP自带局域网聊天47. mem.exe--------显示内存使用情况48. Msconfig.exe---系统配置实用程序49. mplayer2-------简易widnows media player50. mspaint--------画图板51. mstsc----------远程桌面连接52. mplayer2-------媒体播放机53. magnify--------放大镜实用程序54. mmc------------打开控制台55. mobsync--------同步命令56. dxdiag---------检查DirectX信息57. drwtsn32------ 系统医生58. devmgmt.msc--- 设备管理器59. dfrg.msc-------磁盘碎片整理程序60. diskmgmt.msc---磁盘管理实用程序61. dcomcnfg-------打开系统组件服务62. ddeshare-------打开DDE共享设置63. dvdplay--------DVD播放器64. net stop messenger-----停止信使服务65. net start messenger----开始信使服务66. notepad--------打开记事本67. nslookup-------网络管理的工具向导68. ntbackup-------系统备份和还原69. narrator-------屏幕“讲述人”70. ntmsmgr.msc----移动存储管理器71. ntmsoprq.msc---移动存储管理员操作请求72. netstat -an----(TC)命令检查接口73. syncapp--------创建一个公文包74. sysedit--------系统配置编辑器75. sigverif-------文件签名验证程序76. sndrec32-------录音机77. shrpubw--------创建共享文件夹78. secpol.msc-----本地安全策略79. syskey---------系统加密,一旦加密就不能解开,保护windows xp系统的双重密码80. services.msc---本地服务设置81. Sndvol32-------音量控制程序82. sfc.exe--------系统文件检查器83. sfc /scannow---windows文件保护84. tsshutdn-------60秒倒计时关机命令85. tourstart------xp简介(安装完成后出现的漫游xp程序)86. taskmgr--------任务管理器87. eventvwr-------事件查看器88. eudcedit-------造字程序89. explorer-------打开资源管理器90. packager-------对象包装程序91. perfmon.msc----计算机性能监测程序92. progman--------程序管理器93. regedit.exe----注册表94. rsop.msc-------组策略结果集95. regedt32-------注册表编辑器96. rononce -p ----15秒关机97. regsvr32 /u *.dll----停止dll文件运行98. regsvr32 /u zipfldr.dll------取消ZIP支持99. cmd.exe--------CMD命令提示符100. chkdsk.exe-----Chkdsk磁盘检查101. certmgr.msc----证书管理实用程序102. calc-----------启动计算器103. charmap--------启动字符映射表104. cliconfg-------SQL SERVER 客户端网络实用程序105. Clipbrd--------剪贴板查看器106. conf-----------启动netmeeting107. compmgmt.msc---计算机管理108. cleanmgr-------垃圾整理109. ciadv.msc------索引服务程序110. osk------------打开屏幕键盘111. odbcad32-------ODBC数据源管理器112. oobe/msoobe /a----检查XP是否激活113. lusrmgr.msc----本机用户和组114. logoff---------注销命令115. iexpress-------木马捆绑工具,系统自带116. Nslookup-------IP地址侦测器117. fsmgmt.msc-----共享文件夹管理器118. utilman--------辅助工具管理器119. explorer-------打开资源管理器[编辑本段]CMD命令操作详解net use ipipc$ " " /user:" " 建立IPC空链接net use ipipc$ "密码" /user:"用户名" 建立IPC非空链接net use h: ipc$ "密码" /user:"用户名" 直接登陆后映射对方C:到本地为H: net use h: ipc$ 登陆后映射对方C:到本地为H:net use ipipc$ /del 删除IPC链接net use h: /del 删除映射对方到本地的为H:的映射net user 用户名密码 /add 建立用户net user guest /active:yes 激活guest用户net user 查看有哪些用户net user 帐户名查看帐户的属性net localgroup administrators 用户名 /add 把“用户”添加到管理员中使其具有管理员权限net start 查看开启了哪些服务net start 服务名开启服务;(如:net start telnet, net start schedule) net stop 服务名停止某服务net time 目标ip 查看对方时间net time 目标ip /set 设置本地计算机时间与“目标IP”主机的时间同步,加上参数/yes可取消确认信息net view 查看本地局域网内开启了哪些共享net view ip 查看对方局域网内开启了哪些共享net config 显示系统网络设置net logoff 断开连接的共享net pause 服务名暂停某服务net send ip "文本信息" 向对方发信息net ver 局域网内正在使用的网络连接类型和信息net share 查看本地开启的共享net share ipc$ 开启ipc$共享net share ipc$ /del 删除ipc$共享net share c$ /del 删除C:共享net user guest 12345 用guest用户登陆后用将密码改为12345net password 密码更改系统登陆密码netstat -a 查看开启了哪些端口,常用netstat -annetstat -n 查看端口的网络连接情况,常用netstat -annetstat -v 查看正在进行的工作netstat -p 协议名例:netstat -p tcq/ip 查看某协议使用情况netstat -s 查看正在使用的所有协议使用情况nbtstat -A ip 对方136到139其中一个端口开了的话,就可查看对方最近登陆的用户名tracert -参数 ip(或计算机名) 跟踪路由(数据包),参数:“-w数字”用于设置超时间隔。

批处理延时执行命令大全

批处理延时执行命令大全
set /p= <nul
set /p= (alt+数字键盘22为退格键,可在记事本中键入)<nul
for /d %%a in (做 个 语 文 老 师 真 不 容 易 . 以 下 是 学 生 的 造 句 ) do set /p=%%a<nul&ping -n 1 127.1>nul
逐字显示:我是一个中国人
del /f /s /q sleep.vbs
方法四:choice
优点:时间精确,CPU占用低,是最佳选择
@echo off
choice /t 5 /d y /n >nul
start gdh.txt
批处理延时方法小结:
1.ping
@echo off
:loop
echo %time%
::第二行代码说明:“:”和“~”必不可少!“~”后的数字:为正数表示舍弃输出结果的前几位;直接跟负数表示取到输出结果的后第几位。逗号后的数字:为正数表示取到输出结果的前第几位;为负数表示舍弃输出结果的后几位。echo %date:~4% echo %time:~-3% echo %date:~4% %time:~0,-3%
方法一:ping
缺点:时间精度为1秒,不够精确
@echo off
@ping 127.0.0.1 -n 6 >nul
start gdh.txt
方法二:vbs start /wait
缺点:生成临时文件
有点:时间精度为0.001秒,精度高
@echo off
echo wscript.sleep 5000>sleep.vbs
goto loop

电脑命令(常用p处理及用法大全)

电脑命令(常用p处理及用法大全)
修改test.bat内容如下
@echo offecho %1echo %~1echo %0echo %~f0echo %~d0echo %~p0echo %~n0echo %~x0echo %~s0echo %~a0echo %
~t0echo %~z0
再运行cmd,输入 c:\test.bat "/a" /b /c /d可以参照 call/? 或 for/? 看出每个参数的含意注意这里可以对文件进行
find "ok" c:\test.txt && echo 成功如果找到了"ok"字样,就显示"成功",找不到就不显示
24 ||顺序执行多条命令,当碰到执行正确的命令后将不执行后面的命令
find "ok" c:\test.txt || echo 不成功如果找不到"ok"字样,就显示"不成功",找到了就不显示
一般用于 date time label 等需要等待输入的命令
@echo offecho 2005-05-01>temp.txtdate <temp.txtdel temp.txt这样就可以不等待输入直接修改当前日期
28 %0 %1 %2 %3 %4 %5 %6 %7 %8 %9 %*命令行传递给批处理的参数
echo. #输出一个"回车换行",一般就是指空白行
echo hello world #输出hello world
"关闭回显"是指运行批处理文件时,不显示文件里的每条命令,只显示运行结果批处理开始和结束时,系统都会自动打开
回显
2 errorlevel程序返回码
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

1 echo 和@回显控制命令@ #关闭单行回显echo off #从下一行开始关闭回显@echo off #从本行开始关闭回显。

一般批处理第一行都是这个echo on #从下一行开始打开回显echo #显示当前是echo off 状态还是echo on 状态echo. #输出一个"回车换行",一般就是指空白行echo hello world #输出hello world"关闭回显"是指运行批处理文件时,不显示文件里的每条命令,只显示运行结果批处理开始和结束时,系统都会自动打开回显2 errorlevel程序返回码echo %errorlevel%每个命令运行结束,可以用这个命令行格式查看返回码用于判断刚才的命令是否执行成功默认值为0,一般命令执行出错会设errorlevel 为13 dir显示目录中的文件和子目录列表dir #显示当前目录中的文件和子目录dir /a #显示当前目录中的文件和子目录,包括隐藏文件和系统文件dir c: /a:d #显示C 盘当前目录中的目录dir c:\ /a:-d #显示C 盘根目录中的文件dir d:\mp3 /b/p #逐屏显示d:\mp3 目录里的文件,只显示文件名,不显示时间和大小dir *.exe /s显示当前目录和子目录里所有的.exe文件其中* 是通配符,代表所有的文件名,还一个通配符? 代表一个任意字母或汉字如c*.* 代表以 c 开头的所有文件?.exe 代表所有文件名是一个字母的.exe文件如果指定的目录或文件不存在,将返回errorlevel 为1每个文件夹的dir 输出都会有2个子目录. 和... 代表当前目录.. 代表当前目录的上级目录dir . #显示当前目录中的文件和子目录dir .. #显示当前目录的上级目录中的文件和子目录其它参数可参考dir /?4 cd更改当前目录cd mp3 #进入当前目录中的mp3 目录cd .. #进入当前目录中的上级目录cd\ #进入根目录cd #显示当前目录cd /d d:\mp3 #可以同时更改盘符和目录cd\"Documents and Settings"\All users文件名带空格,可以不加引号建议加上引号,因为有的时候不加引号会运行出错,如登录脚本如果更改到的目录不存在,则出错返回errorlevel=15 md创建目录md abc #在当前目录里建立子目录abcmd d:\a\b\c #如果d:\a 不存在,将会自动创建6 rd删除目录rd abc #删除当前目录里的abc 子目录,要求为空目录rd /s/q d:\temp #删除d:\temp 文件夹及其子文件夹和文件,不需要按Y 确认7 del删除文件del d:\test.txt #删除指定文件,不能是隐藏、系统、只读文件del *.*删除当前目录里的所有文件,不包括隐藏、系统、只读文件,要求按Y 确认del /q/a/f d:\temp\*.*删除d:\temp 文件夹里面的所有文件,包括隐藏、只读、系统文件,不包括子目录del /q/a/f/s d:\temp\*.*删除d:\temp 及子文件夹里面的所有文件,包括隐藏、只读、系统文件,不包括子目录8 ren文件重命名ren 1.txt 2.bak #把1.txt 更名为2.bakren *.txt *.ini #把当前目录里所有.txt文件改成.ini文件ren d:\temp tmp #支持对文件夹的重命名9 cls清屏10 type显示文件内容type c:\boot.ini #显示指定文件的内容,程序文件一般会显示乱码type *.txt #显示当前目录里所有.txt文件的内容11 copy拷贝文件copy c:\test.txt d:\复制c:\test.txt 文件到d:\copy c:\test.txt d:\test.bak复制c:\test.txt 文件到d:\ ,并重命名为test.bakcopy c:\*.*复制c:\ 所有文件到当前目录,不包括隐藏文件和系统文件不指定目标路径,则默认目标路径为当前目录copy con test.txt从屏幕上等待输入,按Ctrl+Z 结束输入,输入内容存为test.txt文件con代表屏幕,prn代表打印机,nul代表空设备copy 1.txt + 2.txt 3.txt合并1.txt 和 2.txt 的内容,保存为3.txt 文件如果不指定3.txt ,则保存到1.txtcopy test.txt +复制文件到自己,实际上是修改了文件日期12 title设置cmd窗口的标题title 新标题#可以看到cmd窗口的标题栏变了13 ver显示系统版本14 label 和vol设置卷标vol #显示卷标label #显示卷标,同时提示输入新卷标label c:system #设置C盘的卷标为system15 pause暂停命令运行该命令时,将显示下面的消息:请按任意键继续. . .一般用于看清楚屏幕上显示的内容16 rem 和::注释命令注释行不执行操作17 date 和time日期和时间date #显示当前日期,并提示输入新日期,按"回车"略过输入date/t #只显示当前日期,不提示输入新日期time #显示当前时间,并提示输入新时间,按"回车"略过输入time/t #只显示当前时间,不提示输入新时间18 goto 和:跳转命令:label #行首为:表示该行是标签行,标签行不执行操作goto label #跳转到指定的标签那一行19 find (外部命令)查找命令find "abc" c:\test.txt在c:\test.txt 文件里查找含abc 字符串的行如果找不到,将设errorlevel 返回码为1find /i "abc" c:\test.txt查找含abc 的行,忽略大小写find /c "abc" c:\test.txt显示含abc 的行的行数20 more (外部命令)逐屏显示more c:\test.txt #逐屏显示c:\test.txt 的文件内容21 tree显示目录结构tree d:\ #显示D盘的文件目录结构22 &顺序执行多条命令,而不管命令是否执行成功c: & cd\ & dir /w相当于把下面3行命令写到1行去了c:cd\dir /w23 &&顺序执行多条命令,当碰到执行出错的命令后将不执行后面的命令f: && cd\ && dir >c:\test.txt注意如果f盘不存在,那么后面2条命令将不会执行find "ok" c:\test.txt && echo 成功如果找到了"ok"字样,就显示"成功",找不到就不显示24 ||顺序执行多条命令,当碰到执行正确的命令后将不执行后面的命令f: || e:如果有f盘就不进入e盘find "ok" c:\test.txt || echo 不成功如果找不到"ok"字样,就显示"不成功",找到了就不显示25 |管道命令前一个命令的执行结果输出到后一个命令dir *.* /s/a | find /c ".exe"管道命令表示先执行dir 命令,对其输出的结果执行后面的find 命令该命令行结果:输出当前文件夹及所有子文件夹里的.exe文件的个数type c:\test.txt|more这个和more c:\test.txt 的效果是一样的26 > 和>>输出重定向命令> 清除文件中原有的内容后再写入>> 追加内容到文件末尾,而不会清除原有的内容主要将本来显示在屏幕上的内容输出到指定文件中指定文件如果不存在,则自动生成该文件echo hello world>c:\test.txt生成c:\test.txt文件,内容为hello world这个格式在批处理文件里用得很多,可以生成.reg .bat .vbs 等临时文件type c:\test.txt >prn屏幕上不显示文件内容,转向输出到打印机echo hello world>con在屏幕上显示hello world,实际上所有输出都是默认>con 的copy c:\test.txt f: >nul拷贝文件,并且不显示"文件复制成功"的提示信息,但如果f盘不存在,还是会显示出错信息copy c:\test.txt f: >nul 2>nul不显示"文件复制成功"的提示信息,并且f盘不存在的话,也不显示错误提示信息echo ^^W ^> ^W>c:\test.txt生成的文件内容为^W > W^ 和> 是控制命令,要把它们输出到文件,必须在前面加个^ 符号27 <从文件中获得输入信息,而不是从屏幕上一般用于date time label 等需要等待输入的命令@echo offecho 2005-05-01>temp.txtdate <temp.txtdel temp.txt这样就可以不等待输入直接修改当前日期28 %0 %1 %2 %3 %4 %5 %6 %7 %8 %9 %*命令行传递给批处理的参数%0 批处理文件本身%1 第一个参数%9 第九个参数%* 从第一个参数开始的所有参数在C盘根目录新建test.bat,内容如下:@echo offecho %0echo %1echo %2echo %*运行cmd,输入c:\test.bat "/a" /b /c /d可以看出每个参数的含意修改test.bat内容如下@echo offecho %1echo %~1echo %0echo %~f0echo %~d0echo %~p0echo %~n0echo %~x0echo %~s0echo %~a0echo %~t0echo %~z0再运行cmd,输入c:\test.bat "/a" /b /c /d可以参照call/? 或for/? 看出每个参数的含意注意这里可以对文件进行日期比较和大小比较echo load "%%1" "%%2">c:\test.txt生成的文件内容为load "%1" "%2"批处理文件里,用这个格式把命令行参数输出到文件29 if判断命令if "%1"=="/a" echo 第一个参数是/aif /i "%1" equ "/a" echo 第一个参数是/a/i 表示不区分大小写,equ 和== 是一样的,其它运算符参见if/? if exist c:\test.bat echo 存在c:\test.bat文件if not exist c:\windows (echo 不存在c:\windows文件夹rem 有多条命令可用小括号括起来,称为"复合语句"rem 行前的空格是为了看起来条理清楚)if exist c:\test.bat (echo 存在c:\test.bat) else (echo 不存在c:\test.batrem else表示"否则",判断结果为假时执行其后的命令)30 setlocal 和endlocal设置"命令扩展名"和"延缓环境变量扩充"SETLOCAL ENABLEEXTENSIONS #启用"命令扩展名"SETLOCAL DISABLEEXTENSIONS #停用"命令扩展名"SETLOCAL ENABLEDELAYEDEXPANSION #启用"延缓环境变量扩充" SETLOCAL DISABLEDELAYEDEXPANSION #停用"延缓环境变量扩充" ENDLOCAL #恢复到使用SETLOCAL语句以前的状态"命令扩展名"默认为启用"延缓环境变量扩充"默认为停用批处理结束系统会自动恢复默认值可以修改注册表以禁用"命令扩展名",详见cmd /? 。

相关文档
最新文档