Michael Herz said:
I couldn't agree with you more. I too have had great success with cmd.exe.
I've managed to avoid "(", and ")" problems by rigorously following quote
around filename rules however I've been stumped by "!"s
Unfortunately I have to manage systems where other's are in control of
filenames so I don't have the luxury of forbidding "!"s. I wish MS had done
that as it's core to cmd.exe ;-)
Mike
The .Mount/\Command ".ForExpand" will expand variables
at execution time, providing the same functionality as
"Delayed Expansion", without the hassle.
ForExpand works CONSISTENTLY under NT/2K/XP/K3 using the syntax
%.ForExpand% %%A IN ('SET VariableName') DO (Command %%B)
%%A = VariableName
%%B = Dynamically calculated CONTENTS of VariableName
For a color-keyed example, see
(
http://TheSystemGuard.com/MtCmds/CrystalClear/ForExpand.htm)
ForExpand is part of the (FREE) Advanced Command Library.
(
http://ntlib.com)
When running scripts on systems you don't administer, the Advanced
NT/2K/XP/K3 Command Library fully supports loading across the network from a
Read-Only share point. For example:
CALL \\MachineThatYouDOControl\share\ntlib.cmd /Init /Quiet
*******
This thread has highlighted just one of the reasons that DelayedExpansion is
a "hassle". There were already enough "Syntax Ditches" to cross when
writing shell scripts without adding another layer of complexity with
"!variable!".
Enhanced functionality does NOT have to be more complex. Command Libraries
provide hundreds of additional resources in a self-documenting,
cross-compatible format. This reduces the complexity of the code while
allowing the less experienced administrator to solve complicated problems
using only a "batch file". Most importantly, he or she can actually
UNDERSTAND (!) what is going on.
Remember, shell scripting is the one area of "programming" where many
non-programmers are tasked with "writing a little batch file" when they have
only minimal exposure to a "C:\>" prompt and it's capabilities.
*******
-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)