Setting an Environment Variable

Dennis Faas's picture

It appears that the last issue of the newsletter sparked some real interest amongst many Infopackets Readers (RE: tracert.exe and ping.exe).

At this time, I would like to address the problem that Infopackets Reader Stephen C. wrote to me about not being able to access any MS DOS commands from the command prompt under Windows. He writes:

" When I [attempt to] run [MS DOS commands, such as ping.exe or tracert.exe] under the command window, I get an error message which reads: 'ping' is not recognized as an internal or external command, operable program or batch file. Any ideas? I have Windows 2000. "

There are two reasons for this error:

  1. Ping does not exist in the C:\> root directory;
  2. There is no Environment Variable set on Stephen's system which would normally point the command line to the appropriate directory to issue the ping.exe command.

Both of these problems combined will result in the error message Stephen received.

There is a simple fix which can be applied by editing the autoexec.bat file (described below). But before we get into that, let's look at what the Environment Variables might look like on a Windows 2000 system from the command line using the PATH command: C:\> path


Since Stephen could not access ping.exe from the command line (and any other MS DOS command commonly found in the above directories), it would require him to CHANGE DIRECTORY to the \winnt\system32 where the commands are stored every time he opened up an new command prompt window:

C:\> cd \winnt\system32

C:\winnt\system32> ping

This would provide Stephen with an immediate resolution, but there is a better (long term) solution: setting an Environment Variable for all command line sessions. This can be done by loading NOTEPAD (START -> PROGRAMS -> NOTEPAD) and editing the C:\autoexec.bat file.

Simply add a new line (anywhere) in this file that says:


Note that this Environment Variable will hold true for anyone who has Windows installed on their C drive (either Windows 95, 98, 98SE, ME, NT, XP or 2000.

Finally, save the file and reboot Windows.

After the system has rebooted, a command line can be opened and any MS DOS command can be entered without first having to change directory to either winnt\system32 or windows\command (for all Windows users).

Rate this article: 
No votes yet