FREE
Since you mention it, %.GetOs% CONSISTENTLY fails to determine the correct
OS when the native command interpreter has been replaced. For instance, on
an NT4 machine using cmd.exe from 2000 or XP, %.GetOs% returns '2K' and
'unknown' respectively.
Clarification:
When "the native command interpreter has been replaced", the OS itself is
NOT CONSISTENT, as far as running shell scripts is concerned.
For example:
The "VER" command returns the following:
[NT Cmd.exe running on NT]
Windows NT Version 4.0
[2K Cmd.exe running on NT]
Microsoft Windows 2000 [Version 4.00.1381]
[XP Cmd.exe running on NT]
Microsoft Windows XP [Version 4.0.1381]
[K3 Cmd.exe returns "Entry Point Not Found" when attempting to run on NT]
*******
The text displayed by VER is from the currently running Command Interpreter
but the version numbers are from the actual OS. Even so, the ".GetOS"
Mount/\Command WILL return the correct OS (NT, in this case) as long as the
COMSPEC variable still points to the original Cmd.exe.
This is because .GetOS executes the "VER" command inside a FOR /F statement,
which passes it to a child Cmd.exe. The system determines WHICH Cmd.exe
will be the parent by expanding the COMSPEC variable, so VER will return (in
this case) "Windows NT Version 4.0".
If, while running Windows NT, the COMSPEC variable is changed to point to
the 2K or the XP version of Cmd.exe, GetOS will return inconsistent results
because the internal VER command displays inconsistently, as shown above.
For a color-keyed explanation, see
(
http://TheSystemGuard.com/Booming/THE FIRING ISSUE - 20030108.htm)
*******
Replacing the command interpreter (or other default utilities) is normally
done to correct (perceived) shortcomings and/or deficiencies in the original
files. Most of these deficiencies are easily overcome using what's already
there. Some features, like "delaying the expansion of variables" or
"exiting a script while setting a specific errorlevel", are more cryptic to
code in NT, but not impossible.
To delay variable expansion in NT, see
(
http://TheSystemGuard.com/MtCmds/CommandShorthand/ForExpand.htm)
To exit while setting a specific errorlevel in NT, see
(
http://TheSystemGuard.com/MtCmds/ExitELn)
*******
When using Command Libraries and Mount/\Commands, there is no need to
replace anything because the "fuming special cases" are taken into account
when the Library is initialized. Write your script ONCE and all commands
work CONSISTENTLY across NT/2K/XP/K3 without making any changes to any of
the OS's, and without mixing and matching files.
The cryptic code is still there, but you do not have to remember it and
retype it constantly. All of the code is in ONE FILE (a Command Library)
that provides hundreds of ONE WORD commands that "sound like what they do".
This is the power of Mount/\Commands.
*******
To Mr. Lawrence:
We do not have a record of your licensing any of our products.
The ".GetOS" command is included in the FREE Advanced NT/2K/XP/K3
Library, available at (
http://ntlib.com). Obtaining your own
copy would allow a more accurate analysis of how ".GetOS" performs.
*******
-tsg
____________________________________________________________
TheSystemGuard.com | BoomingOrFuming.com | MountCommands.com
Free and "Almost Free" Knowledge for Windows System Admins!