{"id":412,"date":"2020-09-13T19:42:29","date_gmt":"2020-09-13T17:42:29","guid":{"rendered":"http:\/\/www.myblog.nguenkam.com\/?p=412"},"modified":"2022-04-24T14:35:39","modified_gmt":"2022-04-24T12:35:39","slug":"cmd-commands-you-should-know","status":"publish","type":"post","link":"https:\/\/nguenkam.com\/blog\/index.php\/2020\/09\/13\/cmd-commands-you-should-know\/","title":{"rendered":"CMD Commands you should know"},"content":{"rendered":"\n<p><br>The Windows command prompt is a feature that\u2019s been a core part of the Windows operating system for a long time. There are some CMD commands that are so useful and easy to use that even regular users see the Windows command prompt as a key part of the operating system.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>There are always rumors that it will be phased out at some point, but that\u2019s unlikely to happen any time soon.<\/p><\/blockquote>\n\n\n\n<p>The following are some of the best CMD commands you should know if you want to have more control over your Windows PC.<\/p>\n\n\n\n<h4>1. Delete folders with subfolders<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>rmdir PATH\\TO\\FOLDER-NAME\n\n\/\/OR\nrm PATH\\TO\\FOLDER-NAME<\/code><\/pre>\n\n\n\n<p>The above example removes the  folder with the name <em>&#8220;FOLDER_NAME&#8221;<\/em>.<\/p>\n\n\n\n<p><strong><em>Type the following command to delete folder and subfolders with contents&nbsp;<\/em><\/strong> : <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>rmdir \/s PATH\\TO\\FOLDER-NAME\n\n\/\/OR\n\nrm -r PATH\\TO\\FOLDER-NAME<\/code><\/pre>\n\n\n\n<h4>2. ASSOC: Fix File Associations<\/h4>\n\n\n\n<p>One of the most powerful tools in the CMD command library is the ASSOC command.<\/p>\n\n\n\n<p>Your computer associates certain file extensions with certain programs. This is how your computer knows to open Adobe when you double click a PDF file, or Microsoft Word when you double click a DOC file.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"694\" height=\"277\" src=\"https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2021\/12\/image-7.png\" alt=\"\" class=\"wp-image-1499\" srcset=\"https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2021\/12\/image-7.png 694w, https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2021\/12\/image-7-300x120.png 300w\" sizes=\"(max-width: 694px) 100vw, 694px\" \/><\/figure>\n\n\n\n<p>You can view all the file associations your computer knows about by typing&nbsp;<strong>ASSOC<\/strong>&nbsp;in the command window. You\u2019ll see the file extension and the program it\u2019s associated with.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>You can set the association by typing something like&nbsp;<strong>assoc .doc=Word.Document.8<\/strong>.<\/p><\/blockquote>\n\n\n\n<h4>3. FC: File Compare<\/h4>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"699\" height=\"151\" src=\"https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2021\/12\/image-8.png\" alt=\"\" class=\"wp-image-1500\" srcset=\"https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2021\/12\/image-8.png 699w, https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2021\/12\/image-8-300x65.png 300w\" sizes=\"(max-width: 699px) 100vw, 699px\" \/><\/figure>\n\n\n\n<p>Sometimes when files are changed over time, it\u2019s hard to remember what the differences were between versions. You may not know that a CMD command offers the ability to compare files and see all differences, but it\u2019s true.<\/p>\n\n\n\n<p>The&nbsp;<strong>FC<\/strong>&nbsp;command performs either an ascii or a binary file comparison and will list all of the differences that it finds.<\/p>\n\n\n\n<p><strong>Fc \/a File1.txt File2.txt<\/strong>&nbsp;will compare two ascii files.<\/p>\n\n\n\n<p><strong>Fc \/b Picture1.jpg Picture2.jpg<\/strong>&nbsp;will do a binary compare on two images.<\/p>\n\n\n\n<h4>4. IPCONFIG: IP Configuration<\/h4>\n\n\n\n<p>Network troubleshooting is never simple, but one command that makes it much easier is&nbsp;<strong>IPCONFIG<\/strong>.<\/p>\n\n\n\n<p>Using this command in the CMD command prompt returns detailed information about your current network adapter connection including:<\/p>\n\n\n\n<ul><li>Current IP Address<\/li><li>Subnet Mask<\/li><li>Default Gateway IP<\/li><li>Current domain<\/li><\/ul>\n\n\n\n<p>This information can help you troubleshoot router issues and other connection issues you could be having with your network adapter.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2021\/12\/image-9.png\" alt=\"This image has an empty alt attribute; its file name is image-9.png\"\/><\/figure>\n\n\n\n<h4>5. NETSTAT: Network Statistics<\/h4>\n\n\n\n<p>Concerned that you could have malware running on your computer that\u2019s connecting to internet locations without you knowing about it?<\/p>\n\n\n\n<p>If you run a&nbsp;<strong>NETSTAT<\/strong>&nbsp;command in the command prompt, you can get a list of all active TCP connections from your computer.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/helpdeskgeek.com\/wp-content\/pictures\/2019\/02\/netstat-command.png\" alt=\"\"\/><\/figure>\n\n\n\n<h4>6. PING: Send Test Packets<\/h4>\n\n\n\n<p>An IT Analyst\u2019s best friend is the&nbsp;<strong>PING<\/strong>&nbsp;command. &nbsp;Running this command sends test packets over the network to the target system.<\/p>\n\n\n\n<p>You can use the PING command to test whether your computer can access another computer, a server, or even a website. It can help with revealing network disconnections. It also provides transit time for the packets in milliseconds, so it also reveals a bad network connection as well.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"663\" height=\"285\" src=\"https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2021\/12\/image-10.png\" alt=\"\" class=\"wp-image-1502\" srcset=\"https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2021\/12\/image-10.png 663w, https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2021\/12\/image-10-300x129.png 300w\" sizes=\"(max-width: 663px) 100vw, 663px\" \/><\/figure>\n\n\n\n<h4>7. TRACERT: Trace Route<\/h4>\n\n\n\n<p><strong>TRACERT<\/strong>&nbsp;is a fascinating Windows Command to use. If you\u2019re ever curious to see the path your internet traffic takes to get from your browser to a remote system like Google servers, you can use TRACERT to see it.<\/p>\n\n\n\n<p>The command stands for \u201cTrace Route\u201d, which sends packets out to a remote destination (server or website), and provides you with all of the following information:<\/p>\n\n\n\n<ul><li>Number of hops (intermediate servers) before getting to the destination<\/li><li>Time it takes to get to each hop<\/li><li>The IP and sometimes the name of each hop<\/li><\/ul>\n\n\n\n<p>TRACERT can reveal how the routes of your internet requests change depending where you\u2019re accessing the web. It also helps with troubleshooting a router or switch on a local network that may be problematic.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"667\" height=\"320\" src=\"https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2021\/12\/image-11.png\" alt=\"\" class=\"wp-image-1503\" srcset=\"https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2021\/12\/image-11.png 667w, https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2021\/12\/image-11-300x144.png 300w\" sizes=\"(max-width: 667px) 100vw, 667px\" \/><\/figure>\n\n\n\n<h4>8. POWERCFG: Power Configuration<\/h4>\n\n\n\n<p>Are you frustrated with how quickly your laptop seems to run out of power? It could be that your power settings are configured as efficiently as possible. There\u2019s a windows CMD command called&nbsp;<strong>POWERCFG<\/strong>&nbsp;(power configuration) that can help. Run the command prompt as an administrator and type&nbsp;<strong>powercfg \u2013 energy<\/strong>&nbsp;to get a full power efficiency report.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2021\/12\/image-12.png\" alt=\"This image has an empty alt attribute; its file name is image-12.png\"\/><\/figure>\n\n\n\n<p>The process can take up to about a minute, but when it\u2019s done, you\u2019ll see whether there are any warnings or errors that might help you improve the power efficiency of your system.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"680\" height=\"396\" src=\"https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2021\/12\/image-13.png\" alt=\"\" class=\"wp-image-1505\" srcset=\"https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2021\/12\/image-13.png 680w, https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2021\/12\/image-13-300x175.png 300w\" sizes=\"(max-width: 680px) 100vw, 680px\" \/><\/figure>\n\n\n\n<p>View the energy-report.html file to see the details of those errors and warnings.<\/p>\n\n\n\n<h4>9. SHUTDOWN: Turn Off Computer<\/h4>\n\n\n\n<p>The&nbsp;<strong>SHUTDOWN<\/strong>&nbsp;command is a pretty versatile command that lets you shutdown the computer but control the behavior of that shutdown. It\u2019s commonly used as a scheduled task or part of an IT batch job after patches have been applied to a computer system.<\/p>\n\n\n\n<p>Typing&nbsp;<strong>shutdown \/i<\/strong>&nbsp;from the command prompt will initiate a shutdown, but it\u2019ll upon a GUI to give the user an option on whether to restart or do a full shutdown. If you don\u2019t want to have any GUI pop up, you can just issue a&nbsp;<strong>shutdown \/s<\/strong>&nbsp;command.<\/p>\n\n\n\n<p>There is a long list of other parameters you can use to do a log off, hibernate, restart, and more. Just type&nbsp;<strong>shutdown<\/strong>&nbsp;without any arguments to see them all.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"672\" height=\"457\" src=\"https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2021\/12\/image-14.png\" alt=\"\" class=\"wp-image-1506\" srcset=\"https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2021\/12\/image-14.png 672w, https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2021\/12\/image-14-300x204.png 300w\" sizes=\"(max-width: 672px) 100vw, 672px\" \/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/Force an immediate restart of the computer. (after NULL Second)\nshutdown \/r \/t 0\n\n\/\/Force an immediate restart of the computer after 2minutes = 120 Seconds)\nshutdown \/r \/t 120\n\n\/\/ Force an immediate shutdown of the computer.\nshutdown \/s \/t 0<\/code><\/pre>\n\n\n\n<h4>10. SYSTEMINFO: System Information<\/h4>\n\n\n\n<p>If you need to know what brand of network card you have, processor details, or the exact version of your Windows OS, the&nbsp;<strong>SYSTEMINFO<\/strong>&nbsp;command can help.<\/p>\n\n\n\n<p>This command polls your system and pulls the most important information about your system. It lists the information in a clean format that\u2019s easy to read.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"661\" height=\"411\" src=\"https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2021\/12\/image-15.png\" alt=\"\" class=\"wp-image-1507\" srcset=\"https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2021\/12\/image-15.png 661w, https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2021\/12\/image-15-300x187.png 300w\" sizes=\"(max-width: 661px) 100vw, 661px\" \/><\/figure>\n\n\n\n<h4>11. CHKDSK: Check Disk<\/h4>\n\n\n\n<p>While the SFC command only checks the integrity of core system files, you can use the&nbsp;<strong>CHKDSK<\/strong>&nbsp;command to scan an entire drive.<\/p>\n\n\n\n<p>The command to check the C: drive and repair any problems, launch the command window as an administrator and type&nbsp;<strong>CHKDSK \/f C:<\/strong>.<\/p>\n\n\n\n<p>This command checks for things like:<\/p>\n\n\n\n<ul><li>File fragmentation<\/li><li>Disk errors<\/li><li>Bad sectors<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"477\" height=\"152\" src=\"https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2021\/12\/image-16.png\" alt=\"\" class=\"wp-image-1508\" srcset=\"https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2021\/12\/image-16.png 477w, https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2021\/12\/image-16-300x96.png 300w\" sizes=\"(max-width: 477px) 100vw, 477px\" \/><\/figure>\n\n\n\n<p>The command can fix any disk errors (if possible). When the command is finished, you\u2019ll see a status of the scan and what actions were taken.<\/p>\n\n\n\n<h4>12. SCHTASKS: Schedule Tasks<\/h4>\n\n\n\n<p>Windows comes with a wizard for creating scheduled tasks. For example, maybe you have a BAT file stored on C:\\temp that you want to run every day at noon.<\/p>\n\n\n\n<p>You\u2019d have to click through the Scheduled Task wizard to configure this. Or you can type a single&nbsp;<strong>SCHTASKS<\/strong>&nbsp;command to set it up.<\/p>\n\n\n\n<p><strong>SCHTASKS \/Create \/SC HOURLY \/MO 12 \/TR Example \/TN c:\\temp\\File1.bat<\/strong><\/p>\n\n\n\n<p>The scheduled switch accepts arguments like minute, hourly, daily, and monthly. Then you specify the frequency with the \/MO command.<\/p>\n\n\n\n<p>If you typed the command correctly, you\u2019ll see the response,&nbsp;<strong>SUCCESS: The scheduled task \u201cExample\u201d has successfully been created<\/strong>.<\/p>\n\n\n\n<h4>13. ATTRIB: Change File Attributes<\/h4>\n\n\n\n<p>In Windows, you can change file attributes by right clicking on a file and finding the right property to change. However, instead of hunting around for the file attribute, you can use the&nbsp;<strong>ATTRIB<\/strong>&nbsp;command to set the file attributes.<\/p>\n\n\n\n<p>For example, if you type:&nbsp;<strong>ATTRIB +R +H C:\\temp\\File1.bat<\/strong>, it\u2019ll set File1.bat as a hidden, read-only file.<\/p>\n\n\n\n<p>There is no response when it\u2019s successful, so unless you see an error message, the command worked<\/p>\n\n\n\n<h4>Other Windows CMD Commands<\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\"> <a href=\"https:\/\/ss64.com\/nt\/cls.html\">CLS<\/a>  Clear the screen\n <a href=\"https:\/\/ss64.com\/nt\/cmd.html\">CMD<\/a>  Start a new CMD shell\n <a href=\"https:\/\/ss64.com\/nt\/color.html\">COLOR<\/a>  Change colors of the CMD window\n <a href=\"https:\/\/ss64.com\/nt\/curl.html\">CURL<\/a>  Transfer data from or to a server\n <a href=\"https:\/\/ss64.com\/nt\/call.html\">CALL<\/a>  Call one batch program from another\n <a href=\"https:\/\/ss64.com\/nt\/compress.html\">COMPRESS<\/a>  Compress one or more files\n <a href=\"https:\/\/ss64.com\/nt\/del.html\">DEL<\/a>  Delete one or more files\n <a href=\"https:\/\/ss64.com\/nt\/deltree.html\">DELTREE<\/a>  Delete a folder and all subfolders\n\n <a href=\"https:\/\/ss64.com\/nt\/echo.html\">ECHO<\/a>  Display message on screen\n <a href=\"https:\/\/ss64.com\/nt\/del.html\">ERASE<\/a>  Delete one or more files\n <a href=\"https:\/\/ss64.com\/nt\/explorer.html\">EXPLORER<\/a>  Open Windows Explorer<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"> <a href=\"https:\/\/ss64.com\/nt\/find.html\">FIND<\/a>  Search for a text string in a file\n\n <a href=\"https:\/\/ss64.com\/nt\/mklink.html\">MKLINK<\/a>  Create a symbolic link (linkd)\n <a href=\"https:\/\/ss64.com\/nt\/move.html\">MOVE<\/a>  Move files from one folder to another\n <a href=\"https:\/\/ss64.com\/nt\/moveuser.html\">MOVEUSER<\/a>  Move a user from one domain to another\n <a href=\"https:\/\/ss64.com\/nt\/msg.html\">MSG<\/a>  Send a message\n\n <a href=\"https:\/\/ss64.com\/nt\/set.html\">SET<\/a>  Display, set, or remove session environment variables\n <a href=\"https:\/\/ss64.com\/nt\/setx.html\">SETX<\/a>  Set environment variables\n <a href=\"https:\/\/ss64.com\/nt\/ssh.html\">SSH<\/a>  OpenSSH remote login client\n <a href=\"https:\/\/ss64.com\/nt\/start.html\">START<\/a>  Start a program, command or batch file\n\n <a href=\"https:\/\/ss64.com\/nt\/tasklist.html\">TASKLIST<\/a>  List running applications and services\n <a href=\"https:\/\/ss64.com\/nt\/taskkill.html\">TASKKILL<\/a>  End a running process\n <a href=\"https:\/\/ss64.com\/nt\/tskill.html\">TSKILL<\/a>  End a running process\n <a href=\"https:\/\/ss64.com\/nt\/type.html\">TYPE<\/a>  Display the contents of a text file\n\n <a href=\"https:\/\/ss64.com\/nt\/whoami.html\">WHOAMI<\/a>  Output the current UserName and domain\n\n <\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The Windows command prompt is a feature that\u2019s been a core part of the Windows operating system for a long time. There are some CMD commands that are so useful and easy to use that even regular users see the Windows command prompt as a key part of the operating system. There are always rumors [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[94,93,95,96],"_links":{"self":[{"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/412"}],"collection":[{"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=412"}],"version-history":[{"count":12,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/412\/revisions"}],"predecessor-version":[{"id":1890,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/412\/revisions\/1890"}],"wp:attachment":[{"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=412"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=412"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=412"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}