How To...

This is a collection of batch techniques and tips dating back to the MS-DOS and Windows NT 4 era.
Some of them may have become obsolete by now...

 

...display output on screen

Note: In NT 4 and OS/2, always either terminate echoed text with a space when redirecting, or place the echo command between parenthess () and the redirection outside the brackets, if you are not absolutely certain that the text will not end with a 2.
Otherwise, you may end up with an unwanted redirection of standard error (2>) when you intended to redirect standard output.

ECHO This is test 2>filename.ext

will result in an empty file filename.ext and the text This is test displayed on screen.

ECHO This is test 2 >filename.ext

(note the space following the 2) or

(ECHO This is test 2)>filename.ext

will both redirect the text to filename.ext

...redirect command output to an environment variable:

...ask and receive user input:

...strip characters from strings:

...set errorlevels:

...check date and time:

...convert strings to all uppercase or lowercase:

...insert a delay:


page last uploaded: 22 November 2011, 11:47