home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 8
/
CDASC08.ISO
/
VRAC
/
ENV_31.ZIP
/
ENVIRON.DOC
< prev
next >
Wrap
Text File
|
1993-08-21
|
30KB
|
573 lines
█████████ ███ ███ ███ ███ ███ ████████ ███████ ███ ███
███▒▒▒▒▒▒▒ ████ ███▒ ███▒ ███▒ ███▒ ███▒▒▒███ ███▒▒▒███ ████ ███▒
███▒ █████ ███▒ ███▒ ███▒ ███▒ ███▒ ███▒ ███▒ ███▒ █████ ███▒
████████ ███▒█▒███▒ ███▒ ███▒ ███▒ ████████▒▒ ███▒ ███▒ ███▒█▒███▒
███▒▒▒▒▒▒ ███▒█████▒ ███ ███▒▒ ███▒ ███▒███▒▒ ███▒ ███▒ ███▒█████▒
███▒ ███▒ ████▒ ███▒███▒ ███▒ ███▒ ███ ███▒ ███▒ ███▒ ████▒
█████████ ███▒ ███▒ ▒███▒▒▒ ███▒ ███▒ ███ ███████▒▒ ███▒ ███▒
▒▒▒▒▒▒▒▒▒ ▒▒▒ ▒▒▒ ▒▒▒ ▒▒▒ ▒▒▒ ▒▒▒ ▒▒▒▒▒▒▒ ▒▒▒ ▒▒▒
Version 3.1
August 21, 1993
Copyright 1992, 93 by David E. Key
Arlington, Texas
CompuServe 76264,1532
TABLE OF CONTENTS
_____________________________________________________________________
INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
OVERVIEW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
CHAPTER 1 - SYSTEM REQUIREMENTS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
HARDWARE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
A NOTE ON VIDEO. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
CHAPTER 2 - EXECUTION. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
USER SELECTED. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Delete . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Delete with Configuration File . . . . . . . . . . . . . . . . . . . . . . . . . 6
User Specified Delete. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Restore. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
User Specified Insert. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
AUTOMATIC. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Delete . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Delete with Configuration File . . . . . . . . . . . . . . . . . . . . . . . . . 8
User Specified Delete. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Restore. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
User Specified Insert. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
CHAPTER 3 - COMMAND LINE PARAMETERS. . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
DESCRIPTION. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
AVAILABLE COMBINATIONS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
CHAPTER 4 - RELATED FILES. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
SAVED ENVIRONMENT FILE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
CONFIGURATION FILE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
CHAPTER 5 - LIMITATIONS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
INTRODUCTION
_____________________________________________________________________
ENVIRON's reason for existence is to solve the now quite popular (and rather
irksome) practice of each application needing a battery of environment vari-
ables ... especially those on the network that administrators use to control
the working environment. The program is designed for use in batch files after
the user becomes comfortable with the workings by using the "user selected"
mode. Using a little creativity, you should find it quite easy to accomplish
just about anything that has to do with these little critters.
If you find ENVIRON useful, a gift of any amount would be appreciated. There
is no warranty of any kind. The copyright owner does not warrant that the
software will meet your requirements or that it is error free, nor may the
copyright owner be help responsible for any loss of profits or data. Whether
you like the software or not, I would appreciate any comments related to
problems you're having or suggestions for improvement. Please address all
correspondence to:
David E. Key
6018 Lakehurst Court
Arlington, TX 76016-1024
OVERVIEW
_____________________________________________________________________
ENVIRON is a utility that can be used to delete selected variables from the DOS
master environment, storing those selected to a file before it does so. It can
also be used to restore these saved variables, or a selected subset thereof to
the master environment. In addition, variables and their contents can be
inserted into the master environment much like using DOS' "SET" command. There
are two modes of operation; "user selected" and "automatic".
"User selected" presents a screen showing the variables, and offering the user
the opportunity to mark them for deletion or restoration. There are several
options within this mode that can be specified via command line parameters.
Discussion of these is deferred to the following chapters.
"Automatic" simply runs the program "silently" (i.e. no screens are presented
or messages are printed as long as execution completes successfully). If
execution is completed successfully a value of 0 is returned to DOS upon
termination. Otherwise a value of 1 is returned. This mode also provides for
several command line parameters.
CHAPTER 1 - SYSTEM REQUIREMENTS
_____________________________________________________________________
HARDWARE
--------------------------------------------------------------------------
The ENVIRON.EXE program requires about 96K of memory. It was developed and
tested exclusively under MS-DOS 5.00. How it will behave under another operat-
ing system, I have no idea. However, because of the method used to "grab" the
master environment, I feel fairly comfortable that it should not be a problem.
The code is written in C++ and should run on anything greater than or equal to
an 80x86. There are no floating point routines, so performance with a coproc-
essor is moot. Disk size is certainly no issue. The only additional file
space required by the program is equal to the size in bytes of the variables
removed from the environment plus 2 times the number of variables plus 81
bytes.
A NOTE ON VIDEO
--------------------------------------------------------------------------
ENVIRON writes directly to video memory in "user selected" mode and uses the
following steps to determine what that address should be. First, the mode is
tested and if it is not equal to 7 the address is set to B800h. If the mode is
7, the address used is B000h. If the mode is equal to 3, color is added,
otherwise text is presented in black and white. If you experience video
problems it can probably be traced to the above. "Automatic" mode uses no
video except upon error such as being unable to find the saved environment
file, or being unable to change directories.
CHAPTER 2 - EXECUTION
_____________________________________________________________________
USER SELECTED
--------------------------------------------------------------------------
Delete
------
In "user selected" delete mode a screen similar to the following example
is presented:
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ DELETE MODE ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
╔═════════════════════════════════════════════════════════════════════════════╗
║ ENVIRON.EXE ║
║ Environment Manipulation Utility ║
║ Version 3.1 ║
╚═════════════════════════════════════════════════════════════════════════════╝
√ PROMPT=$P$G
√ TIGA=-MC:\TIGA -LC:\TIGA
√ CLIPPER=F65,R26,V022,E0,X64
√ RIMID=C6
√ COMSPEC=C:\COMMAND.COM
√ PATH=C:\;C:\DOS5;C:\PCTOOLS;C:\UTIL;C:\XTGOLD;C:\BORLANDC\BIN;C:\NORTON; ...
√ S_1=Home
√ S_2=of
√ S_3=the
√ S_4=free
√ S_5=and
┌──────────────────────────────────────────────────────┐
│ Use arrow keys () to highlight item █ F7 to mark │
│ / unmark █ F2 to write selected variables to file │
│ and remove from environment █ F10 to abort operation │
└──────────────────────────────────────────────────────┘
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ PGDN / PGUP for more ... ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
The top line of the screen provides information on the mode of operation.
In this case, "DELETE MODE". The available keys are listed in the out-
lined box near the bottom of the screen. Not shown here, but obvious in
the program, the currently selected item is highlighted in BLACK on
LIGHTGRAY. The arrow keys can be used to move up and down the list of
selections. Those items that are marked with a "√" character are "select-
ed". Selection can be toggled on and off by pressing the F7 key. In this
mode all items are selected by default when the program is started. If
there are more than 11 variables in the environment, a message is dis-
played on the bottom of the screen stating that PGDN or PGUP can be
pressed to view the next (or previous) screen of variables. If any one
variable is greater than 74 characters in length, it is displayed with 3
trailing dots (...). Not to worry, this is merely for cosmetics, the true
value is still "in there." However, you would probably think that a good
program would let you use the right and left arrow keys to view the rest
of it. Unfortunately, this isn't one of those kind of "good ones." Once
all selections have been made, F2 can be pressed to write out the selected
variables to the "save" file and to remove them from the environment. Of
course, there is an abort key ... pressing F10 at any time discards all
changes and returns you to DOS. No changes are made in this instance.
Delete with Configuration File
------------------------------
In "user selected" delete with configuration file mode the screen appears
exactly the same as that for "user selected" delete mode except that the
items specified in the configuration file are rendered unselectable.
Their status is noted on color displays in DARKGRAY on BLUE. On non-color
monitors their colors are LIGHTGRAY on BLACK. It is impossible to over-
ride their status because the arrow keys cannot be used to highlight them.
The top line of screen indicates "RESTRICTED DELETE MODE". See Chapter 4,
"RELATED FILES", for a discussion of the configuration file.
User Specified Delete
---------------------
This mode should not be confused with "user selected" delete mode. In
this mode, wildcard parameters are given that specify which variables
should be marked for deletion by default, as opposed to which variables
should NOT be deleted by using the configuration file, or selecting them
all. Once again, the screen appears exactly the same as that for "user
selected" delete mode except that the items matching the wildcard parame-
ters are marked for deletion with those not matching not being marked.
All items are available for marking/unmarking in this mode. The top line
of screen indicates "DELETE MODE".
The wildcard parameters follow the same form as those used by DOS when
specifying file names to be acted upon by the operating system. The
exception to this is that the "?" character is not supported. If this
character is used, ENVIRON will search for it explicitly in the list of
environment variables. The "*" is supported in one instance only per
wildcard parameter and may occur anywhere in the string. Each wildcard
parameter MUST be separated by one space and should follow a SINGLE "/S:"
parameter. A space after the initial "/S:" specifier is optional. Some
examples:
The parameter "AS*" would find:
ASCII
ASKME
ASTER
it would NOT find:
FAST
RASTER
The parameter "*ED" would find:
ACTED
SUPPORTED
SEPARATED
it would NOT find:
MEDELY
BEDS
The parameter "FILE*BIG" would find:
FILE01BIG
FILE02BIG
it would not find:
FIL001BIG
FIL002BIG
It should be noted that the wildcard specifier is optional. If the "*" is
not found when the selections are being parsed, an explicit match will be
attempted. If the environment variable exists it will be deleted along
with those specified using a wildcard.
Restore
-------
In "user selected" restore mode a screen similar to the following example
is presented:
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ RESTORE MODE ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
╔═════════════════════════════════════════════════════════════════════════════╗
║ ENVIRON.EXE ║
║ Environment Manipulation Utility ║
║ Version 3.1 ║
╚═════════════════════════════════════════════════════════════════════════════╝
√ NU=C:\NORTON
√ S_FILEDIR=Z:\STATION\C6\
√ S_FILE=49
√ S_LOGIN=DAVID
√ S_DRIVE=F:
√ OS=MSDOS
√ VER=V5.00
√ S_DOS=V5.00
√ S_MENU=RISKMAIN
√ S_PROJECT=RISK_MANAGEMENT
√ PRT_GROUP=RISK_PRT
┌──────────────────────────────────────────────────────┐
│ Use arrow keys () to highlight item █ F7 to │
│ mark / unmark █ F2 to insert selected variables │
│ into environment █ F10 to abort operation │
└──────────────────────────────────────────────────────┘
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ PGDN / PGUP for more ... ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
The screen appears exactly the same as that for "user selected" delete
mode except that the F2 key restores the saved environment variables to
the master environment. All other keys perform the same function as that
described above. It should be noted that if all variables from the file
are not restored, those excluded are lost forever. An ASCII file of the
same format could be created to restore these variables later if so
desired.
User Specified Insert
---------------------
In specified insert mode the user may specify variables to insert into the
environment. This option functions virtually the same as DOS' "SET"
command. Each pattern parameter MUST be separated by one space and should
follow a SINGLE "/M:" parameter. A space after the initial "/M:" specifi-
er is optional. For example, "ENVIRON /M:FOO=BAR FCC=COMM", would insert
the variables, "FOO" and "FCC" into the environment with the values of
"BAR" and "COMM" respectively. This option may also be used in conjunc-
tion with restore mode (described above). In this instance those vari-
ables specified with the "/M:" option are inserted into the environment as
well as those found in the saved environment file. It should be noted
that the contents of the "/M:" option will override any identical variable
found in the saved file.
AUTOMATIC
--------------------------------------------------------------------------
Delete
------
"Automatic" delete mode performs the same function as "user selected"
delete mode except that no operator intervention is required or allowed.
Unless some sort of unusual error occurs such as being unable to find a
specified directory or file, operation proceeds "silently" and a value of
0 is returned to DOS upon completion. If an error occurs a value of 1 is
returned to DOS. As with "user selected" delete, the default is to delete
all variables from the environment. This is probably not the desired
effect so "automatic" delete with configuration file mode is provided to
retain those variables contained in the configuration file. Automatic
user specified delete mode can also be used to filter the variables that
are removed.
Delete with Configuration File
------------------------------
"Automatic" delete with configuration file mode operates the same as its
"user selected" cousin except that no operator intervention is required or
allowed. Unless some sort of unusual error occurs such as being unable to
find a specified directory or file, operation proceeds "silently" and a
value of 0 is returned to DOS upon completion. If an error occurs a value
of 1 is returned to DOS. As with the "user selected" mode, the default is
to delete all variables from the environment except those contained in the
configuration file.
User Specified Delete
---------------------
"Automatic" user specified delete mode operates the same as its "user
selected" cousin except that no operator intervention is required or
allowed. Unless some sort of unusual error occurs such as being unable to
find a specified directory or file, operation proceeds "silently" and a
value of 0 is returned to DOS upon completion. If an error occurs a value
of 1 is returned to DOS. As with the "user selected" mode, the default is
to delete all variables from the environment that match the wildcard
parameters specified on the command line.
Restore
-------
"Automatic" restore mode performs the same function as "user selected"
restore mode except that no operator intervention is required or allowed.
Unless some sort of unusual error occurs such as being unable to find a
specified directory or being unable to find the saved environment file,
operation proceeds "silently" and a value of 0 is returned to DOS upon
completion. If an error occurs a value of 1 is returned to DOS. As with
"user selected" restore, the default is to restore all variables to the
environment. If this is not the desired effect, the saved environment
file could be edited to include only those needed.
User Specified Insert
---------------------
"Automatic" user specified insert performs the same function as "user
selected" specified insert except that no operator intervention is re-
quired or allowed. Unless this option is used with the "restore" option
and an error occurs, operation proceeds "silently" and a value of 0 is
returned to DOS upon completion. If an error occurs a value of 1 is
returned to DOS.
CHAPTER 3 - COMMAND LINE PARAMETERS
_____________________________________________________________________
DESCRIPTION
--------------------------------------------------------------------------
Usage:
C:\>ENVIRON </D[-(save file] | /R[-(save file] | /S:<wildcard(s)> |
/M:<pattern(s)>> /C[-(config file] /A /H
Available Parameters:
/H - Display online help screens.
/D[-(save file] - Delete variables from the environment optionally spec-
ifying where to save the variables removed. Or, in
combination with the "/S" parameter, specify where to
save the environment variables.
/C[-(config file] - Use configuration file to specify those variables that
should be excluded from deletion, optionally specify-
ing where to find the configuration file.
/S:<wildcard(s)> - Delete all variables that match a specified pattern
using the familiar DOS "*" wildcard character. Multi-
ple patterns can be specified by separating them with
one space. The "*" wildcard character is not required
in which case the pattern is matched explicitly. Use
in combination with "/D" to specify where the vari-
ables removed from the environment should be stored.
/R[-(save file] - Restore saved variables to the environment, optionally
specifying where to find the saved file if other than
the default.
/M:<pattern(s)> - Insert specific variables and their contents into the
environment. Multiple patterns can be specified by
separating them with one space. May be used in con-
junction with the "/R[-(save file]" parameter to con-
currently restore those variables saved in a file.
/A - Automatic mode, no user intervention required or al-
lowed.
AVAILABLE COMBINATIONS
--------------------------------------------------------------------------
--------------------------------| /H |----------------------------------
Display online HELP screens.
--------------------------| /D[-(save file] |----------------------------
User selected DELETE mode, default is delete all. Optional file name specifies
the drive, path, and name of the file in which to save the variables removed
from the environment. By default this file is saved in the root directory of
the drive on which ENVIRON.EXE resides.
----------------| /D[-(save file] /C[-(config file] |-------------------
User selected DELETE mode, deletes all environment variables except those
specified in the configuration file. The optional, "/D" "save file" parameter
functions the same as outlined above under "/D[-(save file]". Optional "config
file" specifies the drive, path, and name of the configuration file. By
default the configuration file is searched for in the same directory ENVIRON.-
EXE is stored in.
-----------------------| /D[-(save file] /A |---------------------------
Automatic DELETE mode, default is delete all. The optional, "/D" "save file"
option functions the same as outlined above under "/D[-(save file]". This is
not a recommended combination as it will nuke everything in your environment.
--------------| /D[-(save file] /C[-(config file] /A |------------------
Automatic DELETE mode, deletes all environment variables except those contained
in the configuration file. The optional, "/D" "save file" and "/C" "config
file" parameters function the same as outlined above under "/D[-(save file]
/C[-(config file]".
------------------------| /S:<wildcards(s)> |---------------------------
User specified DELETE mode. Deletes only those variables matching the pat-
tern(s) specified as wildcard(s). All wildcard patterns must follow the first
and only "/S:". Subsequent wildcard patterns (after the first) must have 1 and
only 1 space separating them. Those patterns specified without the wildcard
character will be matched explicitly.
----------------------| /S:<wildcards(s)> /A |--------------------------
Automatic DELETE mode. Deletes only those variables matching the pattern(s)
specified as wildcard(s). All wildcard patterns must follow the first and only
"/S:". Subsequent wildcard patterns (after the first) must have 1 and only 1
space separating them. Those patterns specified without the wildcard character
will be matched explicitly.
------------------| /S:<wildcards(s)> /D[-(save file] |-----------------
User selected DELETE mode. "/S:" "wildcard(s)" parameter functions the same as
outlined above under "/S:<wildcards(s)>". The "/D" "save file" parameter
serves ONLY to specify the location for storing the saved environment file.
-----------------| /S:<wildcards(s)> /D[-(save file] /A |---------------
Automatic DELETE mode. Functions the same as outlined above under "/S:<wild-
cards(s)> /D[-(save file]".
-------------------------| /R[-(save file] |----------------------------
User selected RESTORE mode, default is restore all variables contained in the
saved environment file. Optional file name specifies the drive, path, and name
of the file in which the variables removed from the environment are saved. By
default this file is saved in the root directory of the drive on which
ENVIRON.EXE resides. The "save file" option MUST be used if the environment
variables were saved in any location other than the default.
-----------------------| /R[-(save file] /A |---------------------------
Automatic RESTORE mode. Restores all variables contained in the saved environ-
ment file. The optional "save file" specifier functions the same, and with the
same requirements as outlined under "/R[-(save file]".
---------------------------| /M:<pattern(s)> |---------------------------
User selected, specified insert mode. Those patterns specified after the "/M:"
switch are inserted into the environment exactly as typed. Multiple patterns
may be specified by separating them with 1 and only one space.
-------------------------| /M:<pattern(s)> /A |--------------------------
Automatic, specified insert mode. Functions the same as outlined above under
"/M:<pattern(s)>".
-------------------| /M:<pattern(s)> /R[-(save file] |-------------------
User selected, specified insert mode. Functions the same as outlined above
under "/M:<pattern(s)>" with the added option of restoring those variables
contained in the saved environment file. The optional "save file" specifier
functions the same, and with the same requirements as outlined under "/R[-(save
file]".
-----------------| /M:<pattern(s)> /R[-(save file] /A |------------------
Automatic, specified insert mode. Functions the same as outlined above under
"/M:<pattern(s)> /R[-(save file]".
The sequence of these parameters on the command line is insignificant.
Specification of individual parameters must be separated by at least one
space.
CHAPTER 4 - RELATED FILES
_____________________________________________________________________
SAVED ENVIRONMENT FILE
--------------------------------------------------------------------------
Upon executing ENVIRON in any of the delete modes a file entitled
SAVEDENV.TXT is written to the root directory of the disk on which
ENVIRON.EXE resides unless overridden using the "-(save file" option (see
description above). This is a flat, ASCII file that writes each variable
and its associated value (separated by an "=" sign) to its own line in the
file. This file can be edited with a text editor, deleting or adding
lines as desired. Just be sure to follow the same format as that found in
the file created by ENVIRON itself. Each time this file is written a
header precedes the variables identifying it as an ENVIRON.EXE byproduct.
If the resulting file contains no variables it will still be saved to disk
with the header line being its only contents. This allows ENVIRON to
execute in automatic mode without displaying an error message when a
restore is attempted and there is really nothing for ENVIRON to do.
CONFIGURATION FILE
--------------------------------------------------------------------------
A copy of an example configuration file should be included with this
distribution and is entitled ENVIRON.CFG. Unless its location is speci-
fied on the command line, it must reside in the same directory as ENV-
IRON.EXE. The config file is used to identify the variables that should
NOT be deleted when ENVIRON is run with the "/D" parameter. Basically,
variables to exclude are listed on individual lines WITHOUT the associated
"=" sign or the variable's purported contents. Comments can be added by
placing a semicolon anywhere on the line.
CHAPTER 5 - LIMITATIONS
_____________________________________________________________________
There are several limitations in the program worth mentioning. First, the
number of environment variables that the program can handle is limited to 64.
In User Selected Delete Mode, the maximum number of wildcard combinations
following the "/S:" parameter is 15. In User Specified Insert Mode, the
maximum number of patterns is 15 as well. And finally, environment variables
greater than 128 characters in length are not supported.
One "quirk" I have found, and still don't know the reason for, relates to
deleting the "COMSPEC" variable from the environment. The variable is not
visible after using the DOS "SET" command, and restores without problem. But,
shortly after that some or all of the environment variables disappear when
other applications are used. For this reason I would strongly suggest that you
NOT delete the "COMSPEC" variable.