----^--->
/\

//\\
//The\
/Sy
stem\
////
Guard
\

In the mount of the LORD it shall be seen. Genesis 22:14

MountCommands

Booming Or Fuming? | MasterCatalog | ntlib (FREE) | NTCmdLib | MtCmds | Scripts | Almost Free | Help

 

Library Resources

Constants | Functions | GlobalSwitches | GuardNotes | Command Shorthand | MountCommands | Procedures

Types of
.Mt/\Cmds

GetValue | ListValue | NetValue | CrystalClear | ifCondition | SetELn | ifELn | ExitELn | IsPattern | NowValue | RedirRapids | ReliableReporting | RestoreValue | ValueEcho | ExactName

All .Mount/\Commands are dynamically adjusted when loading so as to obtain CONSISTENT RESULTS regardless of the machine that the command is executing on.  All of those Fuming "Syntax Ditches" where commands behave differently on different platforms are bypassed.

So instead of remembering a multitude of "special cases" like

"I need a rope to get over ditch #1"
"I need a shovel to get across ditch #2"
"I need to stand on my left foot and blink my right eye at exactly 6:14PM local time to climb out of ditch #3"

Just use .Mount/\Commands and walk across the bridge!

Now you can get on with whatever you planned to do today instead of spending several fuming hours trying to juggle % signs!


Many commands also have an equivalent in the e[Command] Series.  This series contains "pre-escaped" versions of a .M/\C that can be used inside the ()'s of a FOR loop.

For example,

%.Quiet% SET var

will suppress normal output and only show errors

FOR /F "tokens=* delims=" %%A IN ('%.eQuiet% SET var') DO ECHO:%%A

will do the same thing.


Here's a quick list of .Mount/\Commands:


.Get[value] Series

  1. Retrieve, optionally reformat and display a single value to the console
  2. Place the retrieved value in a variable named #value
  3. Set an errorlevel, if applicable, based on the result

(sample times and dates are based on Wednesday, January 1, 2003 at 7:05:30.07 AM local time)

.Mt/\Cmd

Sample
Output
Description
.GetOS 2K Displays the current Operating System (NT/2K/XP/K3) -AND- updates #os
.GetRole Server Displays the current OS Role (Wkstn OR Server) -AND- updates #Role
.GetCD C:\ Displays the current directory -AND- updates #cd       
.GetIPAddr 172.16.7.77 Displays the current IP Address as nnn.nnn.nnn.nnn, or none or multi) -AND- updates #IPAddr
.GetIPGateway 172.16.7.1 Displays the current Default Gateway Address as nnn.nnn.nnn.nnn, or none or multi) -AND- updates #IPGateway
.GetIPMask 255.255.255.0 Displays the current Subnet Mask as nnn.nnn.nnn.nnn, or none or multi) -AND- updates #IPMask
.GetNic PCI Bus Master Adapter Displays the current Description text from (IPConfig /all) as "text" or none or multi) -AND- updates #nic
.GetMac 00-80-C6-F1-6A-B3 Displays the current MAC (Hardware Address) as nn-nn-nn-nn-nn-nn, or none or multi) -AND- updates #mac
.GetDate Wed 01/01/2003 Displays the current date (format from DATE /T) -AND- updates #date
.GetTime 07:05:30 Displays the current time as hh:mn:ss -AND- updates #time
.GetTimeP 07:05:30.07 Displays the Precise time as hh:mn:ss.hs -AND- updates #timeP
.GetLogDate 20030101 Displays the current date as yyyymmdd -AND- updates #logdate
.GetLogTime 070530 Displays the current time as hhmnss -AND- updates #logtime
.GetLogTimeP 07053007 Displays the Precise time as hhmnsshs -AND- updates #logtimeP

If multiple instances of value are found, the .Get[Value] command will return "multi".  In that case, use the associated .List[Value] command to display all instances, one per line.  If no instances are found, .Get[Value] will return "none".


.List[value] Series

  1. Retrieve, optionally reformat and display one or more instances of value to the console
  2. Set an errorlevel, if applicable, based on the result
     

.Mt/\Cmd

Sample
Output
Description
.ListIPAddr 207.46.249.190
172.16.7.77
Lists one or more IP Addresses as nnn.nnn.nnn.nnn or returns nothing
.ListIPGateway 207.46.249.1
172.16.7.1
Lists one or more Default Gateway Addresses as nnn.nnn.nnn.nnn or returns nothing
.ListIPMask 255.255.255.192
255.255.255.0
Lists one or more Subnet Masks as nnn.nnn.nnn.nnn or returns nothing
.ListNic PCI Bus Master Adapter
3Com 3C90x Ethernet Adapter
Lists one or more NIC "Description" text(s) from "IPConfig /all" as "text" or returns nothing
.ListMac 00-80-C6-F1-6A-B3
00-60-08-AF-71-6F
Lists one or more MACs (Hardware Addresses) as xx-xx-xx-xx-xx-xx or returns nothing

The .ListValue command will list all instances of value, one per line.  If no instances of value are found, nothing will be returned.


.[value]Echo Series

These commands change the behavior of the ECHO command, allowing you to prefix the text to be ECHOed with commonly needed values such as timestamps, etc.  All commands in this series will expand any variable in the optional "Text".

For example:

C:\>SET "var=My message"
C:\>%.ldtEcho% %var%
20030101 070530 My message

.Mt/\Cmd

Sample
Output
Description
.DateEcho [Wed 01/01/2003] Text Echoes "[DATE] Text" to STDOUT.  Date format is like DATE /T, but with no trailing space.  Text is optional.
.dErrEcho [Wed 01/01/2003] Error Message Same as .DateEcho but echoes to STDERR.  Error Message is optional.
.TimeEcho [07:05:30] Text Echoes "[TIME] Text" to STDOUT.  Time is hh:mn:ss with leading 0 added to hours less than 10.  Text is optional.
.tErrEcho [07:05:30] Text Same as .TimeEcho but echoes to STDERR.
.dtEcho [Wed 01/01/2003 @ 07:05:30] Text Echoes "[DATE @ TIME] Text" to STDOUT.  Date like DATE /T, Time hh:mn:ss.
.dtErrEcho [Wed 01/01/2003 @ 07:05:30] Text Same as .dtEcho but echoes to STDERR.
.LogDateEcho 20030101 Text Echoes "yyyymmdd Text" to STDOUT.
.ldErrEcho 20030101 Text Same as .LogDateEcho but echoes to STDERR.
.LogTimeEcho 070530 Text Echoes "hhmnss Text" to STDOUT.
.ltErrEcho 070530 Text Same as .LogTimeEcho but echoes to STDERR.
.ldtEcho 20030101 070530 Text Echoes "yyyymmdd hhmnss Text" to STDOUT.
.ldtErrEcho 20030101 070530 Text Same as .ldtEcho but echoes to STDERR.
.ElEcho [123] Text Echoes "[Errorlevel] Text" to STDOUT.
.ElErrEcho [123] Text Same as .ElEcho but echoes to STDERR.
.ErrEcho Text Echoes "Text" to STDERR.  If no Text is specified, echoes a blank line to STDERR.

.if[Condition]/.ifNot[Condition] Series

These commands are actual IF statements which are dynamically generated when loading the .Mount/\Command Set.  They will evaluate to TRUE or FALSE based on the status of their "Condition".  Most .if commands have an equivalent .ifNot that evaluates exactly opposite.

.Mt/\Cmd

  Description
.ifDOW   TRUE if "Day of Week" is present in the output of DATE /T.  Otherwise FALSE.
.ifOK   TRUE if errorlevel is not 1 or more.  Otherwise FALSE.
.ifErr   TRUE if errorlevel is 1 or more.  Otherwise FALSE.
.ifNT   TRUE if the OS is Windows NT.  Otherwise FALSE.
.if2K   TRUE if the OS is Windows 2000.  Otherwise FALSE.
.ifXP   TRUE if the OS is Windows XP.  Otherwise FALSE.
.ifK3   TRUE if the OS is Windows Server 2003.  Otherwise FALSE.
.ifServer   TRUE if run on a server.  Otherwise FALSE.
.ifWkstn   TRUE if run on a workstation.  Otherwise FALSE.
.ifDC   TRUE if run on a Domain Controller.  Otherwise FALSE.

.is[Pattern]/.isNot[Pattern] Series

.Mt/\Cmd

  Description
.isAlpha   Evaluates TRUE if input is exclusively [A-Z] or [a-z].
.isNOTAlpha   Evaluates TRUE if input includes at least one character that is NOT [A-Z] or [a-z].
.isNum   Evaluates TRUE if input is exclusively [0-9].
.isNOTNum   Evaluates TRUE if input includes at least one character that is NOT [0-9].
.isAlphaNum   Evaluates TRUE if input is exclusively [A-Z], [a-z] or [0-9].
.isNOTAlphaNum   Evaluates TRUE if input includes at least one character that is NOT [A-Z], [a-z] or [0-9].

Is[Pattern] IsNot[Pattern] Series

Command1 Is[Pattern]    Command2
Command1 IsNot[Pattern] Command2

In either case Command2 will only be executed if the output of Command1 matches (or DOES NOT MATCH) the [Pattern].  Available [Patterns] are:

Alpha - matches any upper or lower case letters (A-Z and a-z)
Num - matches numbers (0-9)
AlphaNum - matches letters and numbers (A-Z, a-z, and 0-9)

Examples:

ECHO:%1 %.IsNum% ECHO:The first parameter is numeric.
ECHO:%* %.IsNotAlphaNum% ECHO:Contains non-alphanumeric characters.

This series is also called "Bridge" commands.  Think of it this way.  You can only cross the "bridge" and execute Command2 if you match (or DO NOT MATCH) the [Pattern].


.Redir Rapids Series

These commands control what gets displayed to the console and/or a log file.  They give you complete control over every line of code.  Most of these can be used as a prefix or as a suffix.

COPY Source Destination %.Silent%

is equivalent to

%.Silent% COPY Source Destination

.Mt/\Cmd

  Description
.Silent   Directs all normal output (STDOUT) and all errors (STDERR) to NUL.
.Quiet   Directs only normal output to NUL.  Errors will still be displayed.
.Kity   KITY=Keep It To Yourself.  Directs only errors to NUL.  Normal output will still be displayed.
.Show   Overrides any existing redirection and displays the output of a single command.
.ShowErr   Overrides any existing redirection and displays any errors generated by a single command.
.ShowAll   Overrides any existing redirection and displays all output and errors for a single command.

.SetEL[n]/.ifEL[n]/.ExitEL[n] Series

These commands can be used anywhere in a script to set the errorlevel using ONLY builtin commands.  Commands are dynamically adjusted, when necessary, to PERFORM CONSISTENTLY under NT/2K/XP/K3.

.Mt/\Cmd

  Description
.SetEL123   This command will (silently) set the errorlevel to 123.  You can then check for the exact errorlevel using the associated .ifEL123 command.
.ifEL123   This command will evaluate to TRUE only if the errorlevel is exactly 123, not 124 or higher.
.ExitEL123   This command will (silently) set the errorlevel to 123. and then (GOTO :EOF).  This is useful for setting an errorlevel upon exiting a script or a subroutine.  You can then check the exact errorlevel using the associated .ifEL123 command.

There are .SetEL, .ifEL and .ExitEL commands for errorlevels -1, 0, 1, 2, 3, 4, 123, 129, 161, 255 and 9009.


/\
//\\
//
The\
/Sy
stem\
////
Guard
\
COME ON UP WITH US!
and
Congratulations On Your Decision
to
RISE ABOVE
THE REST!

^
/
!\
/LIB\

TheSystemGuard.com [Revised: 2007-03-29]
Copyright © 1995-2007, JWC
Computer Communications,
All Rights Reserved, Worldwide.
 Disclaimer       Privacy       About Us       More


Communication Is Business!

We Master It With Knowledge!

^
/
.\
/M^C\