Contents of the SETENV.DOC file
SETENV.EXE (Version 1.0)
from PDG Software
SETENV.EXE allows you set an environmental variable to the
standard output of a DOS command. In other words the
variable will be set to whatever you would normally see
printed to the screen.
Usage: SETENV name command /n
Where name is the name of the environmental variable to be
set, command is the DOS command to be executed, and n is
the number of the line from the output to use.
Example 1: Set an environmental variable to the current
C>SETENV CWD CD
The first line of this example shows what environmental
variables are set when we start. There are three
variables set COMSPEC, PATH, and PROMPT. We then do a CD
to show the current working directory. Next we use SETENV
to set the environmental variable CWD to the output of the
CD command. Finally we run SET again to show that the
variable has indeed been added to the environment.
Example 2: Set an environmental variable to the 5th line
of a directory listing.
Volume in drive C has no label
Directory of C:\BIN\PDG
SETENV EXE 20199 1-28-90 2:03p
SETENV DOC 1739 1-28-90 5:23p
2 File(s) 3010560 bytes free
C>SETENV NAME "DIR SETENV.*" /5
NAME=SETENV EXE 20199 1-28-90 2:03p
This example shows how the SETENV command can be used with
complex commands. The second parameter of the SETENV is
the DOS command to be executed which can be more than one
word if it is enclosed in quotes. Also. this example
shows how to use a line other than the first printed. The
last parameter tells SETENV to use the 5th line of the
output of the DIR command, which in this case is the
directory line for SETENV.EXE.
Example 3: A batch file called EXAMPLE.BAT accompanies this
document. It contains an example showing how SETENV might
be used in a batch file.