Using console programs
     
Empower yourself with the Command Prompt ...

Note: For Windows PowerShell usage information please see the end of this article.

About Console Tools
Console applications/tools were originally written to run under old 16-bit operating systems like DOS, but modern 32-bit and 64-bit operating systems like Microsoft Windows still support 16-bit console applications, including 32-bit versions which are known as Win32 Console Applications. Console tools provide administrators, power-users and other curious users with a simple no-fuss text-based interface, which is ideal for many types of programs.

You actually already have many console applications on your system! Most of them can be found in your Windows system or system32 directory. Files such as ping.exe, tracert.exe, netstat.exe, nslookup.exe and several others are all console applications.

Using Console Tools
Console tools are just as easy to start as other programs, but generally they're started from within an open Command Prompt. Otherwise, if you simply try and run a console application (ie. from Explorer) you'll usually just see a black window open and then instantly close.

Whenever you download new console tools, it's recommended you copy them to your system or system32 directory, this way you don't have to worry about where the file is located. OK, let's use a console tool!

STEP #1 of 2 - Opening a command prompt.
From Windows, click on the main "Start" button, and then click "Run..."
Win95/98/ME users type the following and press Enter: command
WinNT/2000/2003/XP users type the following and press Enter: cmd

You should now see the Windows Command Prompt:


STEP #2 of 2 - Running a console tool.
Now that we're inside the Command Prompt we can run console tools. For this example we'll use the nslookup.exe tool which comes with Windows (you'll find it in your system or system32 directory). This tool allows you to resolve network addresses.
Type the following, and press Enter: nslookup www.diamondcs.com.au
You should see something like this:


Congratulations - you can now use console tools! Using DiamondCS console tools is just as easy - simply save the program file (.exe) to your system or system32 directory, go to the Command Prompt, and type the name of the file to run it.


TIP: Most console applications (including DiamondCS ones) support help parameters. This is usually one of the following: -?, ?, /?, -help, /help
    Example: netstat.exe -?


TIP: The textual output of the console can be redirected to a file instead of the screen by appending "> filename" to the end of the command, as seen in the following examples.


TIP: The text output from console applications can be redirected to a file instead of displayed in the console. To do this simply append "> filename" to the end of the commandline. In the following example the output of uptime.exe is redirected to the file result.txt:

C:\DiamondCS>uptime > result.txt

C:\DiamondCS>type result.txt
UpTime - DiamondCS Freeware Console Tools (www.diamondcs.com.au)
---
2 days 0 hrs 55 mins 30.765 secs

C:\DiamondCS>
To append to a file rather than overwriting it use ">>" instead of ">".



Using with Windows PowerShell
Microsoft Windows PowerShell is an extensible command line interface shell that is similar to the Command Prompt but provides greater scripting capabilities in the form of a language similar to C#.

All DiamondCS console applications can be run directly from within Microsoft PowerShell, allowing you to extend their capabilities even further. To run an executable within PowerShell simply prepend "./" before the executable filename:
Windows PowerShell
Copyright (C) 2006 Microsoft Corporation. All rights reserved.
 
PS C:\DiamondCS> ./uptime > result.txt
PS C:\DiamondCS> type result.txt
UpTime - DiamondCS Freeware Console Tools (www.diamondcs.com.au)
---
2 days 0 hrs 55 mins 30.765 secs
PS C:\DiamondCS> _


Back to articles ...
Back to DiamondCS console tools ...

Related websites:
 Microsoft: Command-line Reference A-Z
 Wikipedia: Command Prompt
 Wikipedia: Windows PowerShell



Copyright © 2008, Diamond Computer Systems Pty. Ltd.  All rights reserved.