Wednesday, October 25, 2006

Environment Variables - Path parser

Here's a quick way to display a Windows system search path. The %PATH% environment variable contains a list of folders. When a command is issued at the CMD prompt, the operating system will first look for an executable file in the current folder, if not found it will scan %PATH% to find it.
This script iterates over the path statement, splitting out the individual folders and presents each on a single line.

Use the PATH command to display or change the list of folders stored in the %PATH% environment variable.

To use this, create a new text document and paste the following code.  Save the file as viewpath.cmd and presto!, you can list the contents of your system by doubl-clicking the file:

::viewpath.cmd
@echo off
::echo the path one line at a time
for %%G in ("%path:;=" "%") do @echo %%G
pause

No comments: