MS-DOS (cmd.exe) prompt basic commands

This article is from our Febooti archive, it was relevant then, and I think that it is still relevant today (a few details changed).

Since most of users do not use command prompt as their primary interaction with the operating system then we will go over the pure basics. These commands can also be used in a batch files. Because a batch file is a way of executing frequently entered DOS commands quicker, it would be a good idea to go over some command line basics.

In the previous article there is instruction how to access the command prompt – simply click the Start button (or Windows key on the keyboard) in the lower left hand corner of the screen followed by clicking on the Run… option (or simply typing cmd.exe on newer Windows). When you do this, a small box will appear in the lower left hand corner of the screen. To access the command prompt simply type cmd or command.

cmd.exe
cmd.exe

Now that we have a command prompt up, we will open a program. Let’s start with the Windows calculator. In the black screen you should see something to the extent of C:\>. You might have more to it or you might simply have C:\>. Either way to access the Windows Calculator you simply type calc at this screen. Then hit the enter key on your keyboard. The Windows calculator will pop-up immediately. This is how you are able to open any program from the DOS prompt (technically any program, program’s working folder must be in the path environment variable).

C:\>calc

Windows Calculator
Windows Calculator

One of the most commonly used DOS commands is DIR. The DIR command allows you to view a list of files that are on the disk, and also, to view which files and folders are on what disk. You are also able to view total file count, count of the directories, and all the sizes. You will also find the date and time column useful.

C:\>dir

dir command
dir command

At this point you probably have a bunch of text on your screen right now. What to do? Thankfully, DOS has a very handy command called CLS. Type CLS into your command prompt and hit enter right now. It clears up the screen. You will find this command very useful when playing with your command prompt.

C:\>cls

Back to the DIR command. If that list is too long for you, the DOS allows you to type DIR /p. Yes, just add a /p to the end of that. At this point remember that some of the DOS commands, batch specific commands, and filenames are in capital letters. DOS commands and / or parameters may or may not be case-sensitive.

C:\>dir /p

Performing the command above will display the directory listing but will pause after each screen of information. You will then be told to Press any key to continue… and when you press any key, the next group of information, if any, will be shown.

To see a list of filenames only put a /w as an alternative to the /p. The w stands for Wide and gives you a column name-only list display.

C:\>dir /w

dir /w
dir /w

You are able to view any drive on your computer. To view the listing for a floppy drive enter:
C:\>dir a:

To see the contents of your CD / DVD / Memory Card:
C:\>dir d:

The letter A was the most commonly used drive letter for the floppy drive. This works for other forms of removable storage as well such as flash drives and usually starts with letter D.

Note about dir /p. More universal way of ‘pausing’ long lists, is to use DOS command more. Try to enter the following and see whats happen.

c:\>dir | more

And to see more parameters (or also known as arguments or switches) use the question mark:

c:\dir /?

Next article tomorrow. Click here for the previous article – MS-DOS (cmd.exe) prompt introduction.

This article is from our Febooti archive, it was relevant then, and I think that it is still relevant today (a few details changed).

Edit Sep 19, 2014: added link to the Next article.

MS-DOS (cmd.exe) prompt introduction

This article is from our Febooti archive, it was relevant then, and I think that it is still relevant today.

If you remember the computers of an earlier day then you surely remember the old MS-DOS. If you are of the more recent generation of computer users then you have also probably seen, used or at least heard of MS-DOS. If you are not one of the aforementioned, MS-DOS is an acronym for Microsoft Disc Operating System. This is just yet another Microsoft operating system.

However, unlike the Microsoft operating systems, you are probably used to, Microsoft Windows 95, XP, Windows 7 or Windows 8, for example, you won’t see any neat little graphics to which you are able to click. These newer operating systems are often times called Graphical User Interfaces, or GUI. MS-DOS does not care about anything called an icon, wallpaper or screen saver. Rather than being considered as a Graphical User Interface MS-DOS is what is known as a command-line interface (CLI). You type commands on what is called the command line.

When using a command-line operating system, you enter commands to accomplish tasks. Once you have worked with this type of system you would soon realize that there are many command combinations that you enter frequently. This is where the use of batch files becomes ingenious in that when you want the computer to perform a given combination of commands an abundant number of times, a batch file can store the details of that command combination for swift execution.

Therefore a batch file is a sequence of commands you would typically enter in a command prompt. Batch files are often used to start programs and run utilities. This is because batch files can allow these events to happen with fewer commands. Automation is possible as well to further the advantages of batch. Batch files accomplish all of this while remaining relatively small in file size.

Now, how does this relate to Batch scripts? Once you make a script (program), it will run in this screen. Not exactly. We won’t run our scripts in the actual MS-DOS, more of a watered down readily accessible version Windows provides us. The command prompt – this is where you will see any output produced. This screen, among being called a command prompt, is often referred to as simply a DOS prompt, command line or a MS-DOS prompt.

You are also able to open and modify programs from the command prompt. When writing batch scripts you will soon become quite familiar with this screen. Since most of us are using Windows XP, 7 or 8 that will be the primary operating system for which the examples herein will be for. However when worthy, references will be made towards previous versions of Windows. So, to actually run the batch scripts we make we need to be able to access the command prompt.

Run cmd in Windows 8.1
Run cmd in Windows 8.1
Run cmd in Windows XP
Run cmd in Windows XP

How to get MS-DOS prompt? To access the command prompt you simply click the Start button in the lower left hand corner of the screen followed by clicking on the Run… option. On newer Windows 8 and 8.1, just press Windows key on the keyboard, and type CMD.exe

When you do this, a small box will appear in the lower left hand corner of the screen. To access the command prompt simply type cmd (Windows XP, Vista, 7).

The command prompt is similar to MS-DOS. The command prompt is a great tool that has many great uses. One way of harnessing those uses in one file and not having to type the command for that use each time is through a batch file.

Next article tomorrow.

This article is from our Febooti archive, it was relevant then, and I think that it is still relevant today.

Edit Oct 17, 2014: added link to the next article.

Mystic TCP/IP packet loss and MTU 1504 in Windows 7

We recently have observed some strange things in our local are network. Some Internet resources, mostly from Microsoft, failed to open in any web browser (IE, Firefox, Chrome, Opera, Telnet to port 80). As it happened on all computers, we thought that this is our ISP issue and wrote to support. ISP shortly responded that everything works on their side.

Some random/example resources that didn’t work:

We started to dig deeper. And after some troubleshooting and debugging found, that Microsoft resources do not open because URLs/sites related to CDN does not send any info. The strange thing was, that TCP/IP connection is established, but no data is coming our way (later I learned that partial first packed come through, but it was not visible in Telnet console).

Some of the problematic CDNs:

  • media.ch9.ms
  • ajax.aspnetcdn.com
  • static.ch9.ms

It is important to note, that at this point we thought that this is DNS issue, because everything worked well for our 2nd ISP, and we tried to use IP addresses from our second ISP in Windows hosts file, and sites seemed to start working.

Days past… conversation with our ISP… most of Internet works for us including Gmail, news, etc… Microsoft websites still does not work…

ISP is sending technician to check issue on site. Comes with laptop, and to my big surprise, everything works flawlessly on his PC.

Started to debug, comparing IP addresses, DNS, changing IPs, changing DNS, using Goolge DNS 8.8.8.8, switching cables… and nothing works on our Windows 7 but still works on his laptop.

Out of curiosity I start virtual machine with Windows 7, open IE and… Microsoft sites are opening in virtual machine, that is on the same physical PC.

Ok. Now try to disable Windows Firewall, Antivirus, etc., etc…

Now I clearly see that problem is related to our Windows PCs, not the ISP, so I start to think of all dark scenarios — rootkit, virus, broken hardware driver, broken hardware on all our PC simultaneously… still no progress…

Starting Wireshark. Connection to CDN is established… but data is not coming except partial first packet. Looking closer, Wireshark shows multiple [TCP Previous segment lost] and [A segment before this frame was lost]. Search for this in Google and one topic talks about rare TCP segment loss:
TCP PREVIOUS SEGMENT LOST #REALLY RARE CASE#

This must be it, because it looks like Rare Case :)

From this point it was straightforward. The article talks about MTU size mismatch. The first thing to do, I check MTU for my network adapter. Unfortunately my NIC does not support changing MTU via GUI interface, so I use netsh. How do I change the MTU setting in Windows 7?

To view MTU use the following command:
netsh interface ipv4 show subinterfaces

For me it was mysteriously changed from 1500 to 1504. Still do not know why and how it was changed.

To change it to 1500 (default for Ethernet):
Start command prompt cmd.exe
netsh
interface
ipv4
set subinterface "Local Area Connection" mtu=1500 store=persistent

In my case it was “Local Area Connection 2”.

See also:
The default MTU sizes for different network topologies