New Knowledge for Windows System Admins

  • Thread starter Thread starter guard
  • Start date Start date
G

guard

Shell scripting (aka writing "Batch Files") is something that all Windows
SysAdmins have to do. But the limits of the builtin commands and utilities,
along with a thousand special cases, often frustrate attempts to write a
reliable cross platform script. So we're always trying to find a utility to
do something we can't seem to coax out of the commands Microsoft included.

After dealing with this situation on a daily basis (for about 20 years now,
starting with DOS 2.x), we have developed several FREE and "Almost Free"
products to address this problem. All of these WORK CONSISTENTLY across all
NT-based operating systems including Windows NT4 SP6a+, Windows 2000,
Windows XP and Windows Server 2003.

They require nothing except the commands and utilities that are ALREADY
PRESENT on these systems. There is NO BINARY CODE, only scripting commands.

*******

For example, the simple problem of sending a time-stamped message to the
screen or a log file can easily be accomplished using the ".TimeEcho"
command. The Command Source (.cmdsrc) for the .TimeEcho command is shown
below. Simply cut and paste the code below into a console window on ANY
Windows NT4, Windows 2000, XP or Server 2003 system.

NOTE: Some software will have trouble unwrapping the long lines---so be
sure to paste it as a SINGLE LINE of code. If you are having trouble, a
text only copy, all on one line, is at
(http://TheSystemGuard.com/MtCmds/ValueEcho/TimeEcho.txt).

X-------Begin-Cut-and-Paste-------X

@SET ".TimeEcho=@FOR /F "tokens=* delims=" %] IN ('@FOR /F "tokens=5-7
delims=.:, " %[ IN ^('ECHO:Y^^^|TIME^^^|%SystemRoot%\system32\FindStr.exe
[0-9]'^) DO @^(ECHO:%[^|%SystemRoot%\system32\FindStr.exe/br [0-9][0-9]
^>NUL^&^&^(ECHO:%[:%\:%]^)^|^|^(ECHO:0%[:%\:%]^)^)') DO @CALL ECHO:[%]]"

X-------End-Cut-and-Paste-------X

The above is a "SET" command and will NOT actually run the code. It simply
loads the command .TimeEcho into your local environment. TimeEcho will add a
leading zero to the hours when necessary to keep the output CONSISTENT as
hhmnss. To test it out:

C:\>%.TimeEcho% Your Optional Message Here

[09:00:05] Your Optional Message Here

==========================================

..TimeEcho is a .Mount/\Command. This is a section of scripting code stored
in an environment variable (%.TimeEcho%) under a "sounds like what it does"
name. Instead of copying and pasting several lines of cryptic code, or
downloading another small utility to "Time Echo" some text to the screen or
a log file, just use the one-word self-documenting "Mounted Command".

More info about TimeEcho is at
(http://TheSystemGuard.com/MtCmds/ValueEcho/TimeEcho.htm).

For an explanation of how this .TimeEcho is constructed, see
(http://BoomingOrFuming.com). Specifically, read the sample issues called

"Down In The Details"

and

"A Plain Path Thru Forest FindStr".

*******

There are hundreds of other commands like this,
all in a single library, using only the native
commands and utilities. See the Master Catalog at
(http://TheSystemGuard.com/MasterCatalog.asp).

For a complete list of commands on one page, see
(http://TheSystemGuard.com/MasterCommandList.htm)

The Advanced Library is FREE for personal or commercial use
(http://ntlib.com).

The Expert Library is "Almost Free" at $9 or less per system
(http://NTCmdLib.com).

*******

How much time do you want to save today? And how much do you want to waste?

-tsg
_____________________________________________________________
Communication /*-IS-*\ Business! We Master It With KNOWLEDGE!
If you're tired of trying to slug on thru with old knowledge,
Make a NEW DECISION! Details at (http://TheSystemGuard.com).
 
"obfuscated batch files"

For those who may be tempted to actually believe the above,
look at some sample (FREE) code and judge for yourself. See
(http://TheSystemGuard.com/Scripts/Snapshot/TSG_Snapshot.cmdsrc.htm)

TSG_Snapshot.cmd is included with the FREE Advanced NT/2K/XP/K3
Command Library. Request your copy at (http://ntlib.com).

And if you want to know more details, see here:
(http://TheSystemGuard.com/NoMoreFuming.asp)

*******

Don't let another man's doubt keep YOU in the dark!

-tsg

/-----------------+---------------+----------------------\
| COMPATIBILITY | CLARITY | SPEED |
| Write code ONCE | Make it clear | THEN...Make it fast! |
\-----------------+---------------+----------------------/
400+ command-line resources using ONLY native NT commands!
(http://TheSystemGuard.com/default.asp#MasterCommandList)
 
For example, the simple problem of sending a time-stamped message to the
screen or a log file can easily be accomplished using the ".TimeEcho"
command. The Command Source (.cmdsrc) for the .TimeEcho command is shown
below. Simply cut and paste the code below into a console window on ANY
Windows NT4, Windows 2000, XP or Server 2003 system.

NOTE: Some software will have trouble unwrapping the long lines---so be
sure to paste it as a SINGLE LINE of code. If you are having trouble, a
text only copy, all on one line, is at
(http://TheSystemGuard.com/MtCmds/ValueEcho/TimeEcho.txt).

X-------Begin-Cut-and-Paste-------X

@SET ".TimeEcho=@FOR /F "tokens=* delims=" %] IN ('@FOR /F "tokens=5-7
delims=.:, " %[ IN ^('ECHO:Y^^^|TIME^^^|%SystemRoot%\system32\FindStr.exe
[0-9]'^) DO @^(ECHO:%[^|%SystemRoot%\system32\FindStr.exe/br [0-9][0-9]
^>NUL^&^&^(ECHO:%[:%\:%]^)^|^|^(ECHO:0%[:%\:%]^)^)') DO @CALL ECHO:[%]]"

X-------End-Cut-and-Paste-------X

The above is a "SET" command and will NOT actually run the code. It simply
loads the command .TimeEcho into your local environment. TimeEcho will add a
leading zero to the hours when necessary to keep the output CONSISTENT as
hhmnss. To test it out:

C:\>%.TimeEcho% Your Optional Message Here

[09:00:05] Your Optional Message Here


C:\>alias TimeEcho=`*echo [%_time]`

C:\>TimeEcho Your Optional Message Here
[20:56:57] Your Optional Message Here

C:\>ver

4NT 6.00U Windows XP 5.1

C:\>


Works on Windows NT/2000/XP/2003 (using 4NT or Take Command), Windows
95/98/Me (using 4DOS, 4NT, or Take Command), Windows 3.1 using the 16-
bit version of Take Command, or MS-DOS, PC DOS, or DR DOS using 4DOS
or NDOS. Oh yeah, and OS/2 using 4OS2 or TCOS2.
 
Back
Top