Dec 162017
DOSENV allows you set an environmental variable to the standard output of a DOS command. Useful in batch files. | |||
---|---|---|---|
File Name | File Size | Zip Size | Zip Type |
EXAMPLE.BAT | 592 | 258 | deflated |
SETENV.DOC | 2934 | 942 | deflated |
SETENV.EXE | 20317 | 11205 | deflated |
Download File DOSENV.ZIP Here
Contents of the SETENV.DOC file
SETENV.EXE (Version 1.0)
from PDG Software
Wauwatosa, WI.
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
working directory.
C>SET
COMSPEC=C:\COMMAND.COM
PATH=C:\DOS;C:\BIN;C:\BIN\PDG
PROMPT=$p$g
C>CD
C:\BIN\PDG
C>SETENV CWD CD
C>SET
COMSPEC=C:\COMMAND.COM
PATH=C:\DOS;C:\BIN;C:\BIN\PDG
PROMPT=$p$g
CWD=C:\BIN\PDG
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.
C>SET
COMSPEC=C:\COMMAND.COM
PATH=C:\DOS;C:\BIN;C:\BIN\PDG
PROMPT=$p$g
C>DIR SETENV.*
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
C>SET
COMSPEC=C:\COMMAND.COM
PATH=C:\DOS;C:\BIN;C:\BIN\PDG
PROMPT=$p$g
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.
December 16, 2017
Add comments