พวกเราส่วนใหญ่ใช้ส่วนต่อประสานกราฟิกกับผู้ใช้ (GUI) เนื่องจากสะดวกกว่าการจำบรรทัดคำสั่งแบบเดิม แต่สิ่งหนึ่งที่แน่นอนก็คือ คุณไม่สามารถทำงานทุกอย่างใน GUI ของ Windows ได้ และนั่นคือเวลาที่พรอมต์คำสั่งสามารถให้บริการของคุณได้

อินเทอร์เฟซบรรทัดคำสั่งในตัวนี้สามารถสร้างผลลัพธ์ได้ทันทีโดยใช้คำสั่งง่ายๆ ด้วยทรัพยากรคอมพิวเตอร์ที่น้อยลง ด้วยวิธีนี้ คุณไม่ต้องนำทางผ่านหน้าต่างต่างๆ เพียงเพื่อทำงานเดียวให้เสร็จ ด้วยโปรแกรมนี้ คุณสามารถใช้ฟังก์ชันการดูแลระบบขั้นสูงหรือแก้ไขปัญหาต่างๆ ของ Windows ได้ด้วยตัวคุณเอง!

ในบทความนี้ ฉันจะพูดถึง 50 คำสั่งที่คุณต้องรู้เพื่อใช้งาน Command Prompt แต่หากคุณค่อนข้างใหม่กับยูทิลิตี้นี้ เราขอแนะนำให้ตรวจสอบคู่มือสำหรับผู้เริ่มต้นก่อน

คำสั่งพื้นฐาน

ก่อนที่จะลงลึกถึงคำสั่งหลัก ผมจะเริ่มต้นด้วยคำสั่งพื้นฐาน ไม่ว่าคุณกำลังวางแผนที่จะใช้ Command Prompt อย่างกว้างขวางหรือเพียงเพื่อวัตถุประสงค์ทั่วไป สิ่งเหล่านี้จะเป็นประโยชน์

CommandFunctionclsล้าง Command Prompt screenexitQuits Command Prompthelpให้ความช่วยเหลือด้วยคำสั่งบางอย่างcdย้ายคุณจากไดเร็กทอรีหนึ่ง/ไดรฟ์ไปยังอีกไดเร็กทอรีหนึ่งคลิปคัดลอกเนื้อหาไปยัง Windows คลิปบอร์ดverแสดงเวอร์ชัน Windows ปัจจุบันของคุณ

CLS

คำสั่งนี้เป็นการล้างหน้าจอพรอมต์คำสั่ง หากคุณรู้สึกว่าต้องการเคลียร์พื้นที่ทำงานหลังจากใช้คำสั่งมากเกินไป สิ่งนี้จะมีประโยชน์อย่างมาก สิ่งที่คุณต้องทำคือพิมพ์ cls และกด Enter

Syntax: cls

Exit

หากคุณวางแผนที่จะปิดแอปพลิเคชันพรอมต์คำสั่ง คุณไม่จำเป็นต้องเลื่อนเคอร์เซอร์ เพื่อกดปุ่มปิด เพียงเรียกใช้คำสั่ง exit และโปรแกรมจะปิด

คุณยังสามารถใช้พารามิเตอร์/b เพื่อ ออกจากสคริปต์ชุดงานที่โหลด ด้วยวิธีนี้ หน้าต่างหลักยังคงเปิดอยู่และออกจากแบตช์ไฟล์เท่านั้น อย่างไรก็ตาม หากคุณใช้พารามิเตอร์นอกสคริปต์ พารามิเตอร์จะปิดแอป CMD

ไวยากรณ์: exit/b [รหัสข้อผิดพลาด]
โดยที่รหัสข้อผิดพลาดระบุค่าบางอย่าง จำนวน

ความช่วยเหลือ

คำสั่งนี้เข้ามา สะดวกถ้าคุณเจอคำสั่งใด ๆ และต้องการทราบการทำงานของมัน ซึ่งจะให้ไวยากรณ์พร้อมกับพารามิเตอร์ต่างๆ (สวิตช์)

หากคุณเพียงแค่เรียกใช้ help มันจะแสดงรายการคำสั่งทั่วไปที่ใช้ใน Command Prompt

Syntax: help

อย่างไรก็ตาม ไม่ใช่ทุกคำสั่งที่รองรับยูทิลิตี้นี้ ในกรณีนั้น คุณสามารถใช้เครื่องหมาย/? พารามิเตอร์และควรใช้ได้กับทุกคำสั่ง

ไวยากรณ์:/?

CD หรือ CHDIR

เพียงแค่หมายถึง’เปลี่ยนไดเรกทอรี’และตามชื่อที่แนะนำ เปลี่ยนคุณจากไดเร็กทอรีปัจจุบันตามเส้นทางที่ระบุ

หากคุณเรียกใช้งาน cd มันก็จะแสดงชื่อไดเร็กทอรีปัจจุบันของคุณ ดังนั้น สิ่งสำคัญคือต้องเรียนรู้พารามิเตอร์ต่างๆ พร้อมกับฟังก์ชันและไวยากรณ์:

ParametersFunctionsSyntax:แสดงไดรฟ์พร้อมกับตำแหน่งไดเร็กทอรีสุดท้าย cd ​​::นำคุณไปยังไดเร็กทอรีตามตำแหน่งที่ระบุ cd :/dChanges directorycd/d [ชื่อไดรฟ์]:..นำคุณไปยังก่อนหน้า/รูท directorycd..

หมายเหตุ: คำสั่ง chdir และ cd ดำเนินการเหมือนกัน ดังนั้น คุณสามารถเปลี่ยนไดเร็กทอรีโดยใช้ตัวเลือกที่ต้องการ

คลิป

คำสั่งนี้ คัดลอกเอาต์พุตที่ดำเนินการจากคำสั่งบางคำสั่งไปยังคลิปบอร์ดของ Windows ด้วยวิธีนี้ คุณสามารถคัดลอกข้อมูลไปยังโปรแกรมอื่นได้โดยตรง

การคัดลอกไฟล์ข้อความหรือสคริปต์โดยตรงมีประโยชน์อย่างมากโดยไม่ต้องเปิด ต่อไปนี้คือพารามิเตอร์ที่เกี่ยวข้อง:

ParametersFunctionsSyntaxคัดลอกเอาต์พุตของคำสั่งบางคำสั่งไปที่ คลิปบอร์ดของ Windows | คลิป<ชื่อไฟล์>คัดลอกเนื้อหาของไฟล์บางไฟล์คลิป <ชื่อไฟล์

เวอร์ชัน

Command Prompt ช่วยให้ ดูหมายเลขเวอร์ชันของ Windows ได้อย่างรวดเร็วที่สุดโดยใช้คำสั่งง่ายๆ ด้วยวิธีนี้ คุณสามารถระบุได้ว่ามีการติดตั้ง Windows เวอร์ชันล่าสุดบนคอมพิวเตอร์ของคุณหรือไม่

ไวยากรณ์: ver

คำสั่งของระบบ

ไม่ว่าคุณกำลังพยายามเรียนรู้เกี่ยวกับคอมพิวเตอร์ของคุณหรือทำงานบางอย่างเกี่ยวกับระบบ คำสั่งต่อไปนี้อาจมีประโยชน์:

คำสั่งFunctionpowercfgControls การตั้งค่าระบบไฟฟ้า ปิดเครื่อง ปิดระบบ รีสตาร์ท หรือปิดเครื่องคอมพิวเตอร์ของคุณdriverqueryแสดงไดรเวอร์ที่ติดตั้งทั้งหมดชื่อโฮสต์แสดง ชื่อโฮสต์ systeminfo ของคอมพิวเตอร์แสดงข้อมูลโดยละเอียดเกี่ยวกับระบบของคุณ

Powercfg

ยูทิลิตี้พร้อมรับคำสั่งนี้ช่วยให้คุณสามารถ ควบคุมการตั้งค่าพลังงานโดยรวม ของคอมพิวเตอร์ของคุณ โปรดทราบว่าหากคุณใช้พารามิเตอร์นี้โดยไม่มีพารามิเตอร์ที่เหมาะสม คุณจะพบข้อผิดพลาด”พารามิเตอร์ไม่ถูกต้อง” 

แม้ว่าจะมีพารามิเตอร์มากมาย แต่เราจะพูดถึงเฉพาะพารามิเตอร์ที่พบบ่อยที่สุดด้านล่างเท่านั้น หากต้องการเรียนรู้เพิ่มเติม เพียงเรียกใช้ powercfg/? 

ParametersFunctionsSyntax/list หรือ/lDisplays all Power Scheme ที่มีอยู่ powercfg/list หรือ powercfg/l/deletesettingDelete การตั้งค่าพลังงานเฉพาะ powercfg/deletesetting /setactiveทำให้เป็นแบบแผน ปิดใช้งานโหมดไฮเบอร์เนต powercfg/hibernate [พารามิเตอร์]/availablesleepstates หรือ/aแสดงสถานะโหมดสลีปที่พร้อมใช้งานบนคอมพิวเตอร์ของคุณ powercfg/availablesleepstates หรือ powercfg/a/devicequeryแสดงอุปกรณ์ที่ตรงตามเกณฑ์ที่ระบุ (ค่าสถานะแบบสอบถาม)powercfg/devicequery /deviceenablewake อนุญาตให้อุปกรณ์ที่ระบุ ปลุกคอมพิวเตอร์จาก sleeppowercfg/deviceenablewake /devicedisablewakeปิดใช้งานอุปกรณ์เพื่อปลุกคอมพิวเตอร์จาก sleeppowercfg/devicedisablewake /lastwakeแสดงกิจกรรมที่ปลุกระบบของคุณครั้งล่าสุดจาก sleeppowercfg/lastwake

หากต้องการเรียนรู้คำสั่งด้านบน โดยละเอียด ผมแนะนำให้รัน powercfg/? คำสั่ง <พารามิเตอร์>

ตัวอย่างเช่น หากคุณต้องการทราบข้อมูลเพิ่มเติมเกี่ยวกับพารามิเตอร์/list คุณสามารถเรียกใช้ powercfg/list ได้

Shutdown

น่าสนใจ คุณสามารถ ปิดคอมพิวเตอร์ของคุณ โดยใช้คำสั่งเดียวบน Command Prompt นอกจากนี้ยังสามารถกำหนดเวลากระบวนการปิดเครื่องได้ตามที่คุณต้องการ

ต่อไปนี้เป็นพารามิเตอร์ทั่วไปที่อาจมีประโยชน์:

พารามิเตอร์ฟังก์ชันไวยากรณ์/iOpens ขึ้นกล่องโต้ตอบการปิดเครื่องระยะไกลshutdown/i/l Logs you outshutdown/l/rรีสตาร์ทเครื่องคอมพิวเตอร์ของคุณปิดเครื่อง/r/aยกเลิกการปิดการทำงานshutdown/a/hไฮเบอร์เนตคอมพิวเตอร์ของคุณปิดเครื่อง/h/t xxxตั้งค่าระยะเวลาการหมดเวลาก่อนที่จะปิดเครื่องshutdown/r/t xxx/fEnds แอปพลิเคชันทั้งหมดและลงชื่อคุณออกจากระบบปิดคอมพิวเตอร์/f

หมายเหตุ: การดำเนินการปิดระบบโดยไม่มีพารามิเตอร์จะเรียกใช้ help หรือ/? สำหรับคำสั่งปิดเครื่อง

Driverquery

ต่อไป ไดรเวอร์อุปกรณ์ เป็นส่วนประกอบที่สำคัญของคอมพิวเตอร์ หากคุณต้องการข้อมูลเกี่ยวกับพวกเขา เรามียูทิลิตี้ตัวจัดการอุปกรณ์บน Windows GUI แล้ว

อย่างไรก็ตาม หากคุณต้องการแสดงข้อมูลไดรเวอร์โดยละเอียดในขณะที่ทำงานบนอินเทอร์เฟซบรรทัดคำสั่ง คุณเพียงแค่พิมพ์คำค้นหาไดรเวอร์และ กด Enter

นอกจากนั้น คุณสามารถใช้พารามิเตอร์ต่อไปนี้ซึ่งแต่ละตัวมีฟังก์ชันแยกกัน:

ParametersFunctionsSyntax/s <ระบบ>ระบุชื่อและที่อยู่ IP ของไดรเวอร์คอมพิวเตอร์ของคุณแบบสอบถาม/s [ระบบ]/u <โดเมน> <ชื่อผู้ใช้>ระบุข้อมูลประจำตัวของผู้ใช้และสามารถใช้ได้หลังจาก/s ถูกระบุไดรเวอร์แบบสอบถาม/s [ระบบ]/u [ชื่อผู้ใช้]/p <รหัสผ่าน>ระบุรหัสผ่านของผู้ใช้และสามารถใช้ได้หลังจาก/u ถูกระบุdriverquery/s [ระบบ]/u [ชื่อผู้ใช้]/p [รหัสผ่าน]/fo แสดงผลลัพธ์ในรูปแบบที่ระบุ ตาราง รายการ หรือ csv/fo [table “”not found/]
/nh“No header” หมายความว่าส่วนหัวไม่แสดง (ใช้ไม่ได้กับ/fo list)driverquery/fo [table “”not found/]
/nh/siแสดงไดรเวอร์ที่เซ็นชื่อแล้วไดรเวอร์เคียวรี/si/vแสดงผลแบบละเอียด (ใช้ไม่ได้กับไดรเวอร์ที่เซ็นชื่อ)driverquery/v

ชื่อโฮสต์

คำสั่งนี้ พิมพ์ชื่ออุปกรณ์ หากคุณไม่แน่ใจเกี่ยวกับของคุณหรือกำลังพยายามระบุชื่อโฮสต์บนคอมพิวเตอร์เครื่องอื่น เพียงพิมพ์ชื่อโฮสต์และกด Enter ใน Command Prompt ก็จะแสดงผล

ไวยากรณ์: ชื่อโฮสต์

ข้อมูลระบบ

ไม่เหมือนกับคำสั่งชื่อโฮสต์ ซึ่งจะพิมพ์ข้อมูลโดยละเอียดเกี่ยวกับคอมพิวเตอร์ของคุณ โดยพื้นฐานแล้ว ก็เหมือนกับการเปิดแอปพลิเคชันข้อมูลระบบเพื่อตรวจสอบข้อมูลจำเพาะของพีซีของคุณ

นอกจากนี้ คุณสามารถใช้พารามิเตอร์เดียวกับที่ใช้ใน devicequery (/s,/u,/p,/fo,/nh,/si และ/v) เพื่อพิมพ์ผลลัพธ์ในรูปแบบที่คุณต้องการ

ไวยากรณ์: systeminfo [พารามิเตอร์]

คำสั่งแก้ไขปัญหา Windows

หากคุณประสบปัญหาเกี่ยวกับ Windows อาจ เกิดจากหลายสาเหตุ เช่น ไดรฟ์เสียหาย ไฟล์ระบบ รูปภาพ หรืออื่นๆ อีกมากมาย โดยปกติแล้ว การเรียกใช้เครื่องมือแก้ปัญหาและคำสั่งที่เป็นประโยชน์สามารถแก้ไขปัญหาได้ และนั่นคือสิ่งที่ฉันจะกล่าวถึงในส่วนนี้

คำสั่งฟังก์ชันchkdskตรวจสอบดิสก์ไดรฟ์ของคุณ เพื่อระบุและแก้ไขข้อผิดพลาดที่เป็นไปได้หรือเซกเตอร์เสียsfcสแกนไฟล์ระบบเพื่อระบุไฟล์ระบบที่เสียหายและแทนที่ด้วยไฟล์แคช copydismManages Windows imagesmsdt.exe-id DeviceDiagnosticStarts ตัวแก้ไขปัญหาฮาร์ดแวร์และอุปกรณ์

CHKDSK

คำสั่งนี้จะตรวจสอบดิสก์ภายในเครื่องในคอมพิวเตอร์และแจ้งผู้ใช้เกี่ยวกับข้อผิดพลาดทางตรรกะและทางกายภาพ โปรดทราบว่าการแก้ไขข้อผิดพลาดจะทำได้ก็ต่อเมื่อคุณใช้พารามิเตอร์ต่อไปนี้อย่างชาญฉลาด

ในที่นี้ ข้าพเจ้าได้กล่าวถึงเฉพาะเรื่องทั่วไปเท่านั้น แต่ถ้าคุณต้องการเรียนรู้เพิ่มเติม นี่คือคำแนะนำฉบับสมบูรณ์เกี่ยวกับวิธีเรียกใช้ CHKDSK เพื่อซ่อมแซมและแก้ไขฮาร์ดไดรฟ์

พารามิเตอร์ฟังก์ชันไวยากรณ์สแกนไดรฟ์ข้อมูลที่ระบุ chkdsk :/fแก้ไขข้อผิดพลาดบนดิสก์ที่ถูกล็อค (มิฉะนั้น ระบบจะขอให้คุณถอดไดรฟ์ข้อมูลออกก่อน และทำการสแกนให้เสร็จเมื่อคุณรีสตาร์ทพีซีของคุณ)chkdsk/f/vแสดงเส้นทาง และ ชื่อของทุกไฟล์สำหรับดิสก์ FAT/FAT32 และข้อความการล้างข้อมูลบน NTFSchkdsk/v/rแก้ไขข้อผิดพลาดของดิสก์จริงและดำเนินการทั้งหมดที่พารามิเตอร์/f doschkdsk/r/xForces ไดรฟ์ข้อมูลที่จะถอดก่อนดำเนินการ scanchkdsk/x/iA วิธีที่เร็วกว่าในการสแกนหาข้อผิดพลาดของดิสก์สำหรับ NTFS driveschkdsk/i/offlinescanandfixดำเนินการสแกนแบบออฟไลน์เพื่อแก้ไขข้อผิดพลาดของดิสก์ chkdsk/offlinescanandfix

SFC

Windows System File Checker (SFC) ช่วยคุณ ซ่อมแซมไฟล์ Windows ที่เสียหาย มันทำงานโดยแทนที่ไฟล์ที่เสียหายด้วยสำเนาแคช ซึ่งสามารถเพิ่มประสิทธิภาพการทำงานของคอมพิวเตอร์ได้

ต่อไปนี้เป็นคำสั่ง SFC บางส่วนที่ใช้มากที่สุด:

พารามิเตอร์ฟังก์ชันไวยากรณ์/scannowAll ไฟล์ระบบถูกสแกนและซ่อมแซมsfc/scannow/verifyonlyไฟล์ระบบทั้งหมดถูกสแกน (ไม่มีการซ่อมแซม)sfc/verifyonly/scanfileไฟล์ระบบที่ระบุโดยผู้ใช้จะถูกสแกนและซ่อมแซมsfc/scanfile=[เส้นทางของไฟล์]/verifyfileผู้ใช้-ไฟล์ระบบที่ระบุถูกสแกน (ไม่มีการซ่อมแซม) sfc/verifyfile=[เส้นทางของไฟล์]

DISM

คำสั่งนี้เริ่มเครื่องมือ Deployment Image Service and Management เพื่อกำหนดค่า คุณลักษณะและแพ็คเกจของอิมเมจ Windows มีคำสั่ง DISM มากมายเพื่อใช้เมื่อแก้ไขปัญหา Windows รวมถึง FFU, WIM, Imaging และอื่นๆ แต่ฉันจะพูดถึงพารามิเตอร์ทั่วไปเท่านั้น

เพื่อความสะดวกของคุณ เราได้จัดทำคำแนะนำโดยละเอียดเกี่ยวกับการเรียกใช้คำสั่ง DISM ต่างๆ แล้ว

พารามิเตอร์ฟังก์ชัน ไวยากรณ์/onlineTargets ที่ใช้ OS dism.exe/online [พารามิเตอร์]/imageระบุเส้นทางของ Windows ออฟไลน์ imagedism.exe/image:/list-imageแสดงไฟล์และโฟลเดอร์ทั้งหมดใน Windows imagedism.exe ที่ระบุ/list-image ImageFile:/delete-imageลบอิมเมจ Windows ที่ระบุออกจาก WIM fileism.exe/delete-image/ImageFile:

เคล็ดลับเพิ่มเติม: ถึง เรียนรู้เพิ่มเติมเกี่ยวกับแต่ละคำสั่ง คุณสามารถดำเนินการ/? พารามิเตอร์ในตอนท้าย ตัวอย่างเช่น หากคุณต้องการทราบข้อมูลเพิ่มเติมเกี่ยวกับ/image เพียงดำเนินการ dism.exe/image/?

msdt.exe-id DeviceDiagnostic

เครื่องมือแก้ปัญหาฮาร์ดแวร์และอุปกรณ์ ไม่สามารถใช้กับเครื่องมือแก้ปัญหาอื่นๆ ในการตั้งค่า Windows ได้อีกต่อไป อย่างไรก็ตาม ยูทิลิตีสามารถค้นหาและแก้ไขปัญหาที่เกี่ยวข้องกับส่วนประกอบฮาร์ดแวร์ทั้งหมดได้

ใน Windows 11 คุณสามารถเปิดใช้งานได้โดยใช้คำสั่ง msdt.exe-id DeviceDiagnostic บน Command Prompt

คำสั่งการจัดการไฟล์และไดเร็กทอรี

การจัดการไฟล์และ ไดเร็กทอรีบน Command Prompt อาจยุ่งยากเล็กน้อย อย่างไรก็ตาม ต่อไปนี้คือคำสั่งพื้นฐานบางส่วนที่สามารถทำให้งานของคุณง่ายขึ้น

คำสั่งฟังก์ชันdirแสดงไฟล์และโฟลเดอร์ทั้งหมดภายในไดเรกทอรีสำเนาสำเนา ไฟล์ภายในไดเร็กทอรีหรือจากไดเร็กทอรีหนึ่งไปยังอีกไดเร็กทอรีmoveโอนไฟล์จากไดเร็กทอรีหนึ่งไปยังอีกไดเร็กทอรีdelลบไฟล์หรือไดเร็กทอรีmkdirสร้างไดเร็กทอรีใหม่เปลี่ยนชื่อไฟล์rmdirลบไดเร็กทอรีที่มีอยู่ประเภทแสดงเนื้อหาของไฟล์ข้อความassocแก้ไขประเภทไฟล์fcเปรียบเทียบสองไฟล์และแสดงความแตกต่างattribเปลี่ยนแอตทริบิวต์ของไดเร็กทอรีต้นไม้การแสดงกราฟิกของโครงสร้างไดเร็กทอรี ของเส้นทางที่ระบุ

DIR

สิ่งนี้ คำสั่ง แสดงไฟล์และไดเรกทอรี/ไดเรกทอรีย่อยทั้งหมด จากไดรฟ์/ไดเรกทอรีที่ระบุ

ผู้ใช้ส่วนใหญ่ใช้คำสั่งนี้เพื่อแสดงรายการไฟล์และไดเร็กทอรี สามารถทำได้โดยใช้คำสั่ง dir นอกจากรายการแล้ว ยังแสดงฉลากของวอลุ่ม หมายเลขซีเรียล และจำนวนไฟล์และไดเร็กทอรีทั้งหมด

นอกเหนือจากนั้น คุณยังสามารถใช้พารามิเตอร์ต่อไปนี้:

ParametersFunctionsSyntax <ไดรฟ์>แสดงไฟล์ภายในไดรฟ์ที่ระบุ drivedir [ไดรฟ์]:<เส้นทาง>แสดงไฟล์จากตำแหน่งที่ระบุdir [เส้นทาง]:/bแสดงเฉพาะรายการที่ไม่มีข้อมูลเพิ่มเติมdir/b/sแสดงไฟล์ทั้งหมดภายในไดเร็กทอรี ไดเร็กทอรีย่อย และ filesdir/s/w แสดงรายการไฟล์ทั้งหมดในรูปแบบกว้างdir/w/dเหมือนกับ/w แต่จัดเรียงตามคอลัมน์dir/d

Copy

ตามชื่อที่แนะนำ คำสั่งนี้ คัดลอกไฟล์จากที่หนึ่งไปยังอีกที่หนึ่ง โปรดทราบว่าจะสร้างสำเนาแทนการย้าย

ไวยากรณ์: คัดลอก [ชื่อไฟล์] [เส้นทาง]

ตัวอย่างเช่น หากต้องการคัดลอกไฟล์ example.txt จากไดรฟ์ D ไปยังโฟลเดอร์ Example ในไดรฟ์เดียวกัน นี่คือคำสั่ง I’จะใช้:

copy example.txt Example

Move

คำสั่งนี้ทำงานในลักษณะเดียวกับการคัดลอก อย่างไรก็ตาม ความแตกต่างก็คือ ย้ายไฟล์จากที่หนึ่งไปยังอีกที่หนึ่ง โดยพื้นฐานแล้วเป็นเทคนิคการตัดและวางที่เราใช้ใน GUI ของ Windows

ไวยากรณ์: ย้าย [ชื่อไฟล์] [เส้นทาง]

ตัวอย่างเช่น หากต้องการย้ายไฟล์ example.txt จากไดรฟ์ D ไปยังโฟลเดอร์ Example ในไดรฟ์เดียวกัน นี่คือ คำสั่งที่ฉันจะใช้:

move example.txt Example 

Del or Erase

ทั้งคำสั่ง Del และ Erase สามารถใช้เพื่อ ลบอย่างถาวร ไฟล์ ซึ่งหมายความว่าคุณไม่สามารถเรียกไฟล์กลับจากถังรีไซเคิลได้

ไวยากรณ์: del [ชื่อไฟล์]

ตัวอย่างเช่น หากต้องการลบไฟล์ example.txt อย่างถาวร ฉันจะใช้คำสั่งต่อไปนี้:

del example.txt

หมายเหตุ: แม้ว่าเราจะไม่ได้ระบุพารามิเตอร์และแอตทริบิวต์สำหรับการคัดลอก ย้าย และ del แต่คุณก็ทดสอบด้วยตัวคุณเองได้โดยใช้วิธีใช้หรือ/? พารามิเตอร์.

MKDIR หรือ MD

ทั้งคำสั่ง MKDIR และ MD ใช้เพื่อ สร้างไดเร็กทอรี (โฟลเดอร์) ใหม่ คุณสามารถทำได้ในไดเร็กทอรีปัจจุบันหรือแม้แต่ในไดเร็กทอรีอื่นโดยตรง หมายความว่าคุณไม่จำเป็นต้องย้ายไปยังไดรฟ์/ไดเร็กทอรีนั้นเพื่อสร้างไดเร็กทอรี

Syntax: mkdir [path ]\[ชื่อไดเรกทอรี]

ตัวอย่างเช่น ถ้าฉันอยู่ใน D drive และต้องการสร้างไดเรกทอรีใหม่ นี่คือคำสั่งที่ฉันจะใช้:

mkdir MyDirectory

แต่หากต้องการสร้างไดเร็กทอรีใหม่ในเส้นทางเฉพาะ ฉันจะดำเนินการดังนี้:

mkdir C:\Users\bishu\Desktop\MyDirectory

Rename หรือ Ren

คำสั่ง Ren หรือ Rename เพียงแค่ กำหนดค่าชื่อไฟล์หรือไดเรกทอรีใหม่ ขณะดำเนินการ ตรวจสอบให้แน่ใจว่าคุณไม่ได้ทำซ้ำชื่อกับไฟล์/ไดเร็กทอรีอื่น

ไวยากรณ์: ren [path]/[filename] [new_filename]

จากตัวอย่างเดียวกับด้านบน นี่คือวิธีที่ฉันจะเปลี่ยนชื่อไฟล์สองไฟล์ที่ฉันสร้างไว้ก่อนหน้านี้:

ren MyDirectory MyDir

ren C:\Users\bishu\Desktop\MyDirectory MyDir

RMDIR หรือ RD

ย่อมาจาก ‘ลบไดเรกทอรี’ และนั่นคือสิ่งที่คำสั่งทำ คุณยังสามารถใช้คำสั่งที่สั้นกว่าซึ่งดำเนินการแบบเดียวกัน – RD

ต่อไปนี้คือพารามิเตอร์ทั้งหมดสำหรับคำสั่ง RMDIR:

ParametersFunctionsSyntax\ลบไดเร็กทอรีตามเส้นทางเฉพาะ pathrmdir [path]\[dir_name]/sลบไดเร็กทอรีพร้อมกับไฟล์ทั้งหมดที่อยู่ภายใน (ขอการยืนยัน)rmdir/s [path]\[dir_name]/qลบไดเร็กทอรี พร้อมกับไฟล์ทั้งหมดที่อยู่ในนั้น (ไม่ขอยืนยัน)rmdir/q [path]\[dir_name]

ตามตัวอย่าง ผมจะแสดงวิธีลบไฟล์ MyDirectory ที่ ฉันสร้างไว้ก่อนหน้านี้:

rmdir MyDir

rmdir C:\Users\bishu\Desktop\MyDir

ประเภท

คำสั่งนี้ใช้เพื่อ แสดงเนื้อหาของไฟล์ข้อความบน Command Prompt ด้วยวิธีนี้ คุณไม่ต้องไปยังตำแหน่งที่ต้องการ เปิดไฟล์และปิดอีกครั้งหากไม่จำเป็น

ไวยากรณ์: พิมพ์ [เส้นทาง] [ชื่อไฟล์]
คุณสามารถข้าม [เส้นทาง] หากคุณอยู่ในไดเร็กทอรีเดียวกับไฟล์ข้อความ

รอง

คำสั่งนี้ใช้เพื่อ แสดงหรือจัดการความสัมพันธ์ของนามสกุลไฟล์ต่างๆ โปรดทราบว่าคุณต้องการสิทธิ์ของผู้ดูแลระบบในการแก้ไขการเชื่อมโยง

หากคุณเพียงเรียกใช้คำสั่ง assoc ยูทิลิตีบรรทัดคำสั่งจะแสดงส่วนขยายทั้งหมดพร้อมกับประเภทไฟล์ที่เกี่ยวข้อง

ไวยากรณ์: assoc

นอกจากนี้ คุณสามารถตรวจสอบว่านามสกุลไฟล์ใดเชื่อมโยงกับไฟล์แต่ละประเภท ตัวอย่างเช่น คุณสามารถค้นหาส่วนขยายทั้งหมดที่เกี่ยวข้องกับ’sysfile’ตามที่แสดงในตัวอย่างด้านล่าง

ไวยากรณ์: assoc | ค้นหา “[ประเภทไฟล์]”

ตัวอย่าง:assoc | ค้นหา “sysfile”

คุณสามารถแก้ไขการเชื่อมโยงได้เช่นกัน คุณสามารถเชื่อมโยงนามสกุลไฟล์กับไฟล์ประเภทใดก็ได้ที่คุณต้องการ

ไวยากรณ์: assoc=

ตัวอย่าง: assoc.abc=sysfile

สุดท้าย คุณสามารถลบ สมาคม. อย่างไรก็ตาม คุณจะต้องรีสตาร์ทคอมพิวเตอร์เพื่อใช้การเปลี่ยนแปลง

ไวยากรณ์: assoc [ส่วนขยาย]=

ตัวอย่าง: assoc.abc=

FC

FC ย่อมาจาก”การเปรียบเทียบไฟล์”ซึ่งฟังดูแล้ว ใช้สำหรับ เปรียบเทียบไฟล์สองไฟล์ เพื่อให้คุณสามารถเรียนรู้ เกี่ยวกับความแตกต่าง ดังที่แสดงในการสาธิตด้านบน ฉันได้เปรียบเทียบไฟล์ข้อความสองไฟล์เพื่อทราบความแตกต่างของรายการภายในไฟล์เหล่านั้น

ไวยากรณ์: fc [file1] [file2]

ต่อไปนี้เป็นพารามิเตอร์ที่มีประโยชน์สำหรับคำสั่ง FC:

ParametersFunctionsSyntax/bComparison ในไบนารี modefc /b/c ละเว้นตัวอักษรระหว่างการเปรียบเทียบfc /c/nแสดงหมายเลขบรรทัดfc /n/uการเปรียบเทียบไฟล์ข้อความ Unicodefc /u/w ละเว้นการเว้นวรรคติดต่อกันเมื่อเปรียบเทียบ FC /w

Attrib

คำสั่งนี้ จัดการแอตทริบิวต์สำหรับไฟล์และโฟลเดอร์ คุณสามารถตั้งค่าแอตทริบิวต์อะไรก็ได้ที่คุณต้องการ เช่น ซ่อน อ่านอย่างเดียว ระบบ และอื่นๆ หากต้องการตั้งค่าแอตทริบิวต์ ให้ใช้’+’และหากต้องการลบ ให้ใช้’-‘

ไวยากรณ์: attrib [+/-][attribute_value] [ชื่อไฟล์/โฟลเดอร์]

Attribute ValueDescriptionHHiddenRRead-onlyArchiveSSystemOOfflineINot IndexedXNo scrubVIntegrityPPinnedUUnpinnedBSMR Blob

หมายเหตุ: ฉันยังไม่ได้ กล่าวถึงพารามิเตอร์สำหรับแอตทริบิวต์ (/s,/d และ/l) คุณสามารถใช้/? เปลี่ยนเพื่อเรียนรู้เพิ่มเติมเกี่ยวกับพวกเขา

ต้นไม้

หากคุณต้องการ หากต้องการดูไดเรกทอรีย่อยภายในไดเรกทอรีหรือไดรฟ์ คำสั่ง tree จะทำให้ ดูสวยงามทางกราฟิก จัดโครงสร้างเอกสารในรูปแบบที่ดูง่าย สิ่งที่คุณต้องทำคือรันคำสั่ง tree และระบุพาธหากจำเป็น

ไวยากรณ์: tree [path]

ด้านล่างนี้คือพารามิเตอร์สองตัวที่คุณสามารถนำมาใช้กับคำสั่ง tree:

พารามิเตอร์ฟังก์ชันไวยากรณ์/aแสดงบรรทัดโดยใช้อักขระข้อความแทนการแทนกราฟิกทรี /a/fแสดงรายการทั้งหมดในไดรฟ์/ไดเร็กทอรีทรี /f

คำสั่งการจัดการดิสก์/ไดรฟ์

นอกเหนือจากการจัดการไฟล์และไดเร็กทอรีแล้ว คุณยังสามารถกำหนดค่าดิสก์และไดรฟ์ใน Command Prompt

ต่อไปนี้คือ 7 คำสั่งที่ใช้มากที่สุดสำหรับจุดประสงค์นี้:

คำสั่งฟังก์ชันvolแสดงป้ายกำกับของดิสก์โวลุ่มและหมายเลขซีเรียล รูปแบบรูปแบบ a ไดรฟ์บางตัวในระบบไฟล์ที่ระบุdiskpartManages พาร์ติชันไดรฟ์จัดเก็บdefragDefragments ฮาร์ดไดรฟ์ที่ระบุdiskusageแสดงจำนวนที่ใช้และพื้นที่ว่างบนดิสก์ที่ระบุ

Vol

นี่คือคำสั่งเพื่อตรวจสอบชื่อวอลุ่มหรือหมายเลขประจำเครื่องอย่างรวดเร็ว สิ่งที่คุณต้องทำคือเรียกใช้ vol ด้วยอักษรชื่อไดรฟ์

ไวยากรณ์: vol [dirve_letter]:

รูปแบบ

While there already exists easy-to-use GUI applications for formatting your disk drives, it’s never a bad idea to learn this on Command Prompt.

If you want to format a hard drive having just one partition, the format command should work out for you. However, the better option would be using diskpart, which I shall discuss below.

Here, I’ll only mention the common parameters. Nonetheless, you can go through the other guide that should help you format a hard drive from CMD in detail.

ParametersFunctionsSyntax/vSpecifies the volume label of the drive you’re trying to formatformat/v:

Diskpart

This is a command-line interpreter that offers disk management features on Command Prompt. With this utility, you can assign drive letters, manage the drive attributes, configure partitions, display disk information, format a drive, and much more.

Type diskpart and this should launch the interpreter. However, you require administrative privilege to use it.

In the table below, I have mentioned the most used commands in Diskpart. If you wish to learn more about disk partitions using the diskpart command, you can check out our dedicated guides for both HDD and SSD.

CommandFunctionsSyntaxlistDisplays the volumes, disks, partitions, or virtual disks based on the parameter specifiedlist selectSelects a volume, disk, partition, or virtual disk based on the parameter specifiedselect createCreates a volume, partition, or virtual disk file based on the parameter specifiedcreate assignAssign a drive letter or mount point to the selected volumeassign formatFormats a diskformat exitExits the Diskpart interpreterexit

Defrag

Defragmentation simply means reorganizing the data inside an HDD to achieve better performance (not recommended on SSD).

Like any other action, Windows already offers a dedicated utility.

However, if you wish to know this in detail, Command Prompt offers tons of parameters that should help you out. Note that this command requires administrative privilege.

ParametersFunctionsSyntax:Defrags the specified drive (traditional defragmentation, default parameter is set to/d)defrag :/aAnalyzes the selected drivedefrag :/a/bPerforms boot optimization on the selected drivedefrag :/b/cRuns operations on all the volumesdefrag :/c/hRuns operations in normal prioritydefrag :/h/uPrints the progressdefrag :/u

Diskusage

This might not be the most used command but is definitely worth it. You can get the summarized details on the selected disk’s usage in no time.

Simply executing the diskusage command should do the job (note that you need to open CMD as an administrator). Along with that, you can take a look at the following parameters that might be beneficial:

ParametersFunctionsSyntax/cDisplays the result in CSV formatdiskusage/c :/hDisplays the result in human-readable formatdiskusage/h :/s Displays size for system files onlydiskusage/s :

Networking Commands

Unlike others, networking commands are widely used mainly for troubleshooting purposes. In fact, fetching IP addresses or configuring network settings is much easier on Command Prompt than using GUI components.

If you’re a networking enthusiast, here are the commands that you need to focus on: 

CommandFunctionnetManage network and its settingsipconfigDisplays detailed information about your network configurationnetshStarts the Netsh prompt that lets you manage network configurationsnetstatDisplays active network connectionspingVerifies IP-level connectivity and reachabilitytracertChecks the computer’s path to connect to the networkpathpingTraces the route to the target and also displays the statistics (combination of ping and tracert)getmacDisplays the MAC addressnslookupDisplays the information about domain names and IP addresses

Net

You can use this command to manage different networking services. It comes with multiple options each performing a specialized task.

Here, I’ve only mentioned the most common ones. You can execute the net command without a parameter to get more.

OptionFunctionaccountsConfigures login requirementscomputerManages computers in the domaincontinueRestarts a servicestartStarts a networking servicestopStops a networking serviceviewDisplays all the devices in a networkstatisticsDisplays network statistics

Ipconfig

This command is for network configuration and management. You can view the detailed Windows TCP/IP information, release/renew IP addresses, flush the DNS cache, and much more.

Executing ipconfig without parameters displays the IPv4, IPv6, subnet mask, and default gateway for every adapter. For other purposes, you can adopt the following parameters:

ParametersFunctionsSyntax/allDisplays TCP/IP configuration for all adaptersipconfig/all/flushdnsFlushses the DNS client resolver cacheipconfig/flushdns/release Releases the DHCP configuration for the specified adapter (you can simply execute the/release parameter to release the configuration for all the adapters at once)ipconfig/release /renew Renews DHCP configuration for the specified adapter (if not specified, renews for all the adapters)ipconfig/renew

Netsh

This is another essential networking command used for managing network configurations. You can execute netsh to launch the dedicated shell. After that, you can perform desired networking operations using some of the well-known parameters from the below table:

CommandsFunctionsdhcpclientManages the DHCP client servicednsclientManages DNS client settingsfirewallManages the Windows firewall serviceinterfaceManages physical or virtual network adapterslanManages LAN settings on your computerwlanManages wireless network settings on your computernamespaceManages namespace configurationsofflineSets the mode to offlineonlineSets the mode to onlinequit/exit/byeExits the Netsh shellwinsockManages Winsock settings

Additional Tip: You can further learn about each of the above command’s arguments using ? in the netsh shell or use the/? parameter with the netsh command.

Netstat

This command lists the active connections on your computer. It displays the protocol, local as well as foreign address, and the current state. Just executing the netstat command will list the active TCP connections.

To display other protocols, here are some parameters you can use:

ParametersFunctionsSyntax-aDisplays all the active TCP and UDP connections netstat-a-bDisplays all active connections along with each process (requires admin privilege)netstat-b-eDisplays the interface statisticsnetstat-e

Ping

This command is widely used for testing host-server reachability and internet connectivity. Executing ping displays the IP address statistics and the approximate round trips in milliseconds.

Here are a few parameters that I recommend trying out: 

ParametersFunctionsSyntax-tContinues displaying stats until interrupted by pressing CTRL+Cping-t -nDisplays stats based on the specified number of echo Request messagesping-n -lDisplays stats based on the specified lengthping-l

Tracert

This command traces the route to a certain IP or domain by sending ICMP or ICMPv6 messages with increasing TTL values. It’s extremely useful during network troubleshooting as it informs users about the routing issues and validates the network paths.

Implementing the tracert command without a parameter traces the route of the specified domain/IP over a maximum of 30 hops.

Nevertheless, you could make use of the following parameters to gain additional networking information:

ParametersFunctionsSyntax-hDisplays results in ‘n’ no. of maximum hops specifiedtracert-h -dDoesn’t resolve IP address making the results appear much fastertracert-d -wSpecifies the maximum time to wait for echo Reply message (if not, displays *)tracert-w -4Uses IPv4 to trace the routetracert-4 -6Uses IPv6 to trace the routetracert-6

Pathping

This command is a combination of Tracert and Ping. When executed without a parameter, it traces the route to the target over a maximum of 30 hops and computes statistics for 125 seconds (by default).

Here are some of the most used pathping parameters:

ParametersFunctionsSyntax-hDisplays results based on the maximum hops specifiedpathping-h -pWaits between consecutive pings before displaying the statspathping-p -wSpecifies the maximum time to wait for each replypathping-w -4Only uses IPv4pathping-4 -6Only uses IPv6pathping-6

Getmac

If you wish to get the MAC address of your computer, you can execute the getmac command and this will display the result in no time. The result includes both the physical address and the transport name.

Along with that, I highly recommend trying out the following parameters:

ParametersFunctionsSyntax/s Displays the results for the specified computer name of IP addressgetmac/s /fo

Displays in the specified formatgetmac/fo

/nhDisplays in the table or CSV format excluding the column headergetmac/nh

NSLookUp

This is yet another command-line utility that includes numerous commands to obtain domain name or IP address information. To start the prompt, simply type nslookup in the Command Prompt and hit Enter.

While there are countless parameters for nslookup, I’m only going to focus on a few common ones in the table below:

CommandsFunctionsfingerConnection with finger serverlsDisplays DNS domain informationlserverChanges default server to the specified DNS using current serverserverChanges server to the specified DNS using default serversetDifferent parameters (all, class, d2, etc.) are used to set various DNS-related settings

Miscellaneous

If you have implemented each of the commands I’ve discussed, you should now be proficient enough to use Command Prompt. However, the aforementioned commands are not enough to master this Windows command-line interface.

There are thousands more, and it’s impossible for me to include all of them in this single post.

For now, I would recommend trying out the following commands that could come in handy while you’re on the way to mastering Command Prompt:

CommandFunctiontasklistDisplays all the currently running processestaskkillKills a processpowershellStarts Windows PowerShell sessionsetManages Windows environment variablesstartRuns the specified programbcdbootRepairs the boot environmentdateDisplays today’s datepromptChanges the cmd textcolorCustomizes foreground and background color

Tasklist

You can use this command to display the currently running processes on your computer. Executing tasklist lists down the name of the process, its PID, session name, session number, and memory usage. Also, you can try out the following parameters:

ParametersFunctionsSyntax/s Displays all the processes of the specified computer name or IP addresstasklist/s /mDisplays all the modules of currently running processestasklist/m/fo

Displays the results in a specified formattasklist/fo

/nhDisplays the results in table or CSV format without the header columntasklist/nh/svcDisplays all the services associated with the currently running processestasklist/svc

Taskkill

While the tasklist command displays the processes, taskkill kills/ends them. You can use either process ID or image name to do this task. Therefore, you need to utilize any of the following common parameters:

ParametersFunctionsSyntax/pid Kills the process as per the specified process IDtaskkill/pid /im Kills the process as per the specified image nametaskkill/im /fEnds the process forcefullytaskkill/f /tEnds the process along with all the child processestaskkill/t

Powershell

If you prefer Windows PowerShell over CMD, you can actually run the Command Prompt as a Powershell window. Just type powershell and hit Enter. You’ll likely get the PS prefix indicating that you can now run all the Powershell cmdlets here.

Syntax: powershell

Set

This command is used for configuring the Windows environment variables. To display all the available ones, you can use the set command without any parameters. In order to set a new environment variable, you can use a variable name and provide the necessary value.

Syntax: set [variable_name]=[value]

Likewise, it’s possible to delete any environment variable too. Below is the syntax that should clear your doubt.

Syntax: set [variable_name]=

The set command on Command Prompt has the following two parameters with individual functionality:

ParametersFunctionsSyntax/aSets the variable name as a line of inputset/a =/pSets the value as a numerical expressionset/p =

Start

You can use this command to launch a new Command Prompt window. Without the use of any parameter, it will simply launch the new prompt. However, utilizing the following parameters can help you perform just more than that:

ParametersFunctionsSyntax“title”Launches the CMD window with the specified titlestart ““/d Starts the CMD window with the specified pathstart/d or Launches the CMD windows in restored or maximized windowstart /waitStarts the application and waits for it to end (meaning you cannot execute further commands in the main prompt)start/wait

BCDBoot

Most users utilize this command to repair the boot environment from the Windows Recovery Environment. It works by copying the Windows installation files to a system partition. You need to execute bcdboot with the following parameters:

ParametersFunctionsSyntax/lSpecifies an optional language during BCD store initializationbcdboot/l  /sSpecifies the system partition’s label where the BCD files will be copied tobcdboot/s /dPreserves the existing default windows boot entrybcdboot/d /bcdcleanCleans the BCD storebcdboot/bcdclean

Date

This is another useful command to quickly check the current date. You can display or set a new date as per your requirement. If you execute just the date command, the prompt displays the date and asks you to set a new one. But if you quickly want to check the date, use the/t parameter.

Syntax: date/t

Prompt

This command offers customization of the text that appears in front of the cursor (by default, it’s the current directory path).

You can change this to any character string of your choice or predefined characters (like current date, drive, path, times, windows version, etc.) using special codes. You can check using the/? Parameter. To switch back to the normal format, execute the prompt without any parameters.

Syntax: prompt [text/special_code]

Color

Certainly, you have thought of customizing the Command Prompt. To your surprise, it’s possible to tweak the default black (background) and white (foreground/text) combination. For this, you require specifying two hex digits—the first representing the background and the second corresponding to the text.

Syntax: color [hexcode]

Hex DigitColor0Black1Blue2Green3Aqua4Red5Purple6Yellow7White8Grey9Light BlueALight GreenBLight AquaCLight RedDLight PurpleELight YellowFBright White

As per the above table, let’s say you want a red background with light blue text. So, you’ll have to execute the following command:
color 49

While you’re at it, note that you cannot set the same background and foreground colors. Even if you do it, the command will not execute and you’ll be left with the existing combination.

To switch back to default, run the color command without any parameter.

Categories: IT Info