Error Messages - Make Invisible

T

tbassngal

I am new to MS-DOS programming and would like to know how
I can get
the error messages not to appear in the following code:

IF EXIST C:\Docume~\All
Use~\Documen~\ADM_026~\Databas~\Fronten~\Training GOTO
NEXT1
REM Echo ***** TRAINING DIRECTORIES *****
Md "C:\Documents and Settings\All
Users\Documents\ADM_026_032_036
\Databases\FrontEnd\Training"
:NEXT1

When the directory exists, I still get a message that say
directory
already exists... or in similar code (below) will get an
error message
that the system cannot find file specified. These are
normal messages
for the code that I have written, but I do not want the
user to see
them... it confuses the heck out of them.

rmdir /S /Q C:\Docume~1\%USERNAME%~NAM\

Please help! Thank you - I know this must be simple,
correct? I've
tried the if not exist and if exist goto, etc.
 
D

David Trimboli

You can redirect both output and errors to "nul". 1 is stdout and 2 is
stderr.
For instance,

md MyDir 2>nul

This will redirect any errors created by the command to "nul", which means
it will dump them into nowhere.

You can put redirection statements at the beginning of the line. Some
people find this improves readability when you use longer or more complex
lines. For instance:

2>nul md MyDir

For more information on redirection, look in the index under "Command
Reference" and find the "Redirection" subtopic.

Your script, by the way, is failing because you're not getting those "short
names" right. Windows will usually take the first six letters of a name
(skipping spaces) and append ~# (where # is 1-9). (If there are more than
nine names that begin with the first six letters, I believe Windows starts
taking only the first five letters, and appending ~##, where ## is 10-99.)
You're not using the numbers.

The correct short name for Documents and Settings is usually C:\DOCUME~1.

I recommend that you use full names in quotation marks, rather than short
names. You can't always predict the short name.

David
Stardate 3832.7
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top