ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[¤À¨É] ¦ó¿×§å¦¸ÀÉ(Batch File)¡H

[¤À¨É] ¦ó¿×§å¦¸ÀÉ(Batch File)¡H

§å¦¸Àɪº³W®æ¡G

01.­º¥ý§å¦¸ÀÉ­n¥H¯Â¤å¦r¼g¥X¡A¬O¤@ºØ¤å¦rÀɮס]ASCIIÀɮס^¡A¥Ñ¤@³s¦êªºMS-DOS©R¥O©Ò²Õ¦¨ªº¡A¨C¤@¦æ³£¬O¤@±øDOS«ü¥O¡]¤j³¡¤À®É­Ô´N¦n¹³§Ú­Ì¦bDOS´£¥Ü¸¹¤U°õ¦æªº«ü¥O¦æ¤@¼Ë¡^¡A¨C¤@¶µ«ü¥O¡]¥]¬A¤º³¡«ü¥O©M¥~³¡«ü¥O¡^­n¦b¤@¦æ¤¤§¹¦¨¡A¤£¯à¤À¨â¦æ¡A¨C¦æ³Ì¦h¬O 127 ­Ó¦r¡A¨â­Ó«ü¥O´N­n¤À¨â¦æ (©Î¥Î³sµ²²Å¸¹)¡C ¦Ó§å¦¸³B²zªº¯à¤O¥D­n¨ú¨M©ó§A©Ò¨Ï¥Îªº«ü¥O¡C

02.¨ä¦¸§å¦¸Àɪº©R¦W³W«h»P¤@¯ëÀɮ׬ۦP¡A§Y "±N ¤@³s¦êªº©R¥O" Àx¦s¦bÀɮפ¤¡AÀɮצW©T©w­n¥Î .bat ¬°°ÆÀɦW(¦bnt/2000/xp/2003¤U¤]¥i¥H¥Î.cmd)¡A°£¤F Autoexec.bat¡A¥DÀɦW¥Ñ¨Ï¥ÎªÌ¦Û©w¡A¦ý³Ì¦nÁקK©M DOS «ü¥O¦P¦W¡A¨Ò¦p¤£­n¥Î Copy.bat¡BDel.bat¡BDir.bat¡BExit.bat µ¥µ¥¡A¸Ó§å¦¸Àɪº«ü¥O¥iµL­­¨îªº­«ÂШϥΡA¥Ã»·±o¨ì¬Û¦Pªº°õ¦æµ²ªG¡C

03.§å¦¸ÀɻݥΠDOS «ü¥O¥[¤W¯S©w»y¦¸¼g¦¨¡A³o¨Ç«ü¥O¥]¬A DOS ¤º³¡¤Î¥~³¡«ü¥O¡A»yªk¦³¥H¤U¦U¶µ¡G
  call choice echo
   for...in...do goto if(if exit)(if not exist)
   pause rem shift
¡@«ü¥O¿ù»~·|¦³ "Bad command or file name" ¦^À³¡A»yªk¿ù»~·|¦³ " Syntax error" ªº¦^À³¡C

04.­n DOS °õ¦æ§å¦¸Àɪº«ü¥O¡A¥u»ÝÁä¤J¥DÀɦW¡A¨Ò¦p Menu.bat ©Î menu¡C¤£¹L­Y§å¦¸Àɪº¥DÀɦW©M .com ©Î .exe ªº¥DÀɦW¬Û¦P®É¡A´N­nÁä¤J¥þ¦W¡A¨Ò¦p§å¦¸Àɪº¦WºÙ¬O copy.bat ©Î edit.bat®É¡A´N­nÁä¤Jcopy.bat ©Î edit.bat ¤~¯à¨Ï¹q¸£°õ¦æ§å¦¸Àɪº«ü¥O¡A§_«h¹q¸£·|°õ¦æ copy.exe ©Î edit.com ³o¨Ç DOS «ü¥O¡C

05.¦b§å¦¸ÀÉ°õ¦æ³~¤¤¡A¤@°_«ö¤U [Ctrl]+[C] ©Î [Ctrl]+[Break] ¥i²×¤îµ{§Ç¡C«ö¤U³o¨â­ÓÁä«á¡A¿Ã¹õ·|Åã¥Ü¡GTerminate batch job (y/N)? «ö [Y] ·|²×¤î³o§å¦¸ÀÉ©M¦^¨ì DOS ªº´£¥Ü¸¹¡A«ö [N] «h¨ú®ø[Ctrl]+[C] «ü¥O¡A§å¦¸ÀÉ·|Ä~Äò°õ¦æµ{§Ç¡C

06.¦­´Á¦bDOS¨t²Î¤u§@¤U¡A³£¥i¯à»Ý­n¨Ï¥Î§å¦¸ÀɨӰõ¦æ¹q¸£¤u§@¡A·í¤å¦r¤¶­±ªº¨t²Î³vº¥³QWindows¡BUnix¨t²Î¡]¹Ï§Î¤¶­±¡^©Ò¨ú¥N®É¡A²{¤µ¤@¯ë¨Ï¥Î¹q¸£ªº¤H¡A¥i¯à¤]¤£¬O«Ü²M·¡¤°»ò¬O§å¦¸ÀÉ¡A§Ú­Ì¤µ¤Ñ´N¨Ó¤¶²Ð¦ó¿×§å¦¸ÀÉ¡C

07.³o­Ó¤å¥ó§A¥i¥H¨Ï¥ÎDOS¤UªºEdit©ÎªÌWindowsªº°O¨Æ¥»(notepad)µ¥¥ô¦ó¤å¥»¤å¥ó½s¿è¤u¨ã·s¼W©M­×§ï§å¦¸³B²z¤å¥ó¡A¦b©R¥O´£¥Ü¤UÁä¤J§å¦¸ÀɦWºÙ©Î¬O´å¼Ð·Æ¹«¥ªÁäÂùÀ»§å¦¸ÀÉ¡A¨t²Î·|½Õ¥ÎCmd.exe¨Ó¹B¦æ§å¦¸ÀÉ¡C

08.§å¦¸³B²z¤å¥ó¬O¤@ºØ²³æªºµ{§Ç¡A¥i¥H³q¹L±ø¥ó»y¥y(if)©M¬yµ{±±¨î»y¥y(goto)¨Ó±±¨î«ü¥O°õ¦æªº¬yµ{¡A¦b§å¦¸³B²z¤¤¤]¥i¥H¨Ï¥Î´`Àô»y¥y(for)¨Ó´`Àô°õ¦æ¤@±ø«ü¥O¡C

09.·íµM¡A§å¦¸³B²z¤å¥óªº½sµ{¯à¤O»PC»y¨¥µ¥½sµ{»y¥y¤ñ°_¨Ó¬O¤Q¤À¦³­­ªº¡C¨C­Ó½s¼g¦nªº§å¦¸³B²z¤å¥ó³£¬Û·í©ó¤@­ÓDOSªº¥~³¡«ü¥O¡A§A¥i¥H§â¥¦©Ò¦bªº¥Ø¿ý©ñ¨ì§AªºDOS·j´M¸ô®|(path)¤¤¨Ó¨Ï±o¥¦¥i¥H¦b¥ô·N¦ì¸m°õ¦æ¡C

10.¤@­Ó¨}¦nªº²ßºD¬O¦bµwºÐ¤W«Ø¥ß¤@­Óbat©ÎªÌbatch¥Ø¿ý¡]¨Ò¦pC:\BATCH¡^¡AµM«á±N©Ò¦³§A½s¼g ªº§å¦¸³B²z¤å¥ó©ñ¨ì¸Ó¥Ø¿ý¤¤¡A³o¼Ë¥u­n¦bpath¤¤³]©w¤Wc:\batch¡A§A´N¥i¥H¦b¥ô·N¦ì¸m°õ¦æ©Ò¦³§A½s¼gªº§å¦¸³B²zµ{§Ç¡C

°õ¦æ­±
• ±N¦h­Ó«ü¥O¸m©ó¦P¤@ÀɮסAÅýOS¤@¦¸°õ¦æ(¦Û°Êªº³sÄò°õ¦æ¦h±ø«ü¥O)
• ¤å¦r®æ¦¡¡A¥ÑWindowsªºcmd.exe¸ÑŪ
• ´£¨Ñ¦hºØ«ü¥O
  §å¦¸«ü¥O(cmd.exe´£¨Ñ)
   ¤º³¡«ü¥O(cmd.exe´£¨Ñ)
   ¥~³¡«ü¥O(OS/User´£¨Ñ)
• ª©¥»ºt¶i¡GDOS -> Win9x -> Win2000/WinXP
• §å³B²zªºÀɮפå¥ó°ÆÀɦW¬° .bat ©Î .cmd¡C   
• ¤j¤p¼g¤£±Ó·P¡]©R¥O¦r¤¸©¿²¤¤j¤p¼g¡^
• ÀuÂI¡Gcmd.exe¬°OS¤º«Ø¡A³q¥Î¡B²³æ¡B¤£¥Î½sĶ¡C¯S§O¾A¥Î©ó¤å¦rÀÉ¡A³B²z¥Î§å¦¸³B²z¡A´N¥i¥H¹ê²{±N³o¨Ç³Â·Ðªº¾Þ§@²³æ¤Æ¡C
• ¯ÊÂI¡G³t«×¤£§Ö¡BµLªk¼¶¼g½ÆÂø°Ê§@¡A

À³¥Î­±
• ±Æµ{©w®É¡GGUI¤è¦¡¡B§å¦¸Àɪ©¥»
• §ó§ïIP¡GGUIª©¥»¡B§å¦¸ª©¥»
• µn¤J®ÉÅÜ´«®à­±
• ¦Û°Ê¦¬°e«H
• ¦Û°Êµn¤Jbbs
• ¦Û°Êftp¤U¸ü
• ¦Û°Ê¤Ægoogle¬d¸ß
• ¦Û°Ê¤ÆMP3À£ÁY
• ¦Û°Ê³Æ¥÷¸ê®Æ
• ¦Û°Ê¤Æ¶Ç°e²°T
• ¦Û°Ê³]©w·j´M¸ô®|
• ¦Û°Ê½Õ¤J·Æ¹«ÅX°Ê©MºÏ·Þ§Ö¨ú
• ¦Û°Ê³]©w¨t²ÎÀô¹ÒÅܼÆ
• ¦Û°Ê²M²z©U§£.¶}±Òµ{¦¡.¨t²ÎÃö¾÷................
• ÁÙº¡¦hªº,«Ý«áÄò¶K¤å¦@¦P°Q½×

        ÀR«ä¦Û¦b : ¬°¤H³B¥@­n¤p¤ß²Ó¤ß¡A¦ý¤£­n¡u¤p¤ß²´¡v¡C
ªð¦^¦Cªí ¤W¤@¥DÃD