Copyright © 2003-2010 by Prof.
Last modified Thu 13-May-2010 09:20:13
Assorted NT/2000/XP/.. CMD.EXE Script Tricks
From the html version of the tscmd.zip 1cmdfaq.txt file
To the Description and the Index
This page is edited from the 1cmdfaq.txt faq-file contained in
command line interface (CLI) collection. That zipped file has much
additional material, including a number of detached .cmd script
files. It is recommended that you also get the zipped version as a
Please see "The Description and
the Index page
" for the conditions of usage and other such
82} Why does echo 9>temp.txt fail while echo 10>temp.txt works?
A cmd.exe feature. The sole digit nine is taken to be a file handle
0-9 when redirection is used. You'll have to escape it e.g. applying
>temp.txt echo 9
The problem might be particularly insidious in a case like this
(also see item #86
@echo off & setlocal enableextensions
for %%c in (type del) do call %%c tmp$$$.txt
endlocal & goto :EOF
The output will be
ECHO is off.
That can be avoided by using
>tmp$$$.txt echo %var_%
What does one do with a file handle? Try this without having a
diskette in the drive
dir a: > temp.dir
What you'll get is on the screen
The device is not ready.
But if you would rather that the line went into the temp.dir file,
dir a:> temp.dir 2>&1