Re: Batch file help



Pegasus (MVP) wrote:
"MSBhhNish" <MSBhhNish@xxxxxxxxxx> wrote in message
news:45629214.1000602@xxxxxxxxxxxxx
Pegasus (MVP) wrote:
"MSBhhNish" <MSBhhNish@xxxxxxxxxx> wrote in message
news:45627755.70707@xxxxxxxxxxxxx
I have a batch file that I wrote on a Win2K system where
I have something like:
copy file1.txt f:\file2.txt > NUL:
On win2K if I have an error, such as not enough room on f:,
the error message is displayed on the Console window. If
no error, the "1 file(s) copied" message goes out to null.

However on WinXP, both the stdout and stderr message goes
to NUL:. Is there a way to write the copy command so
that it emulates Win2K?

TIA
Try this:
copy file1.txt f:\file2.txt 1> NUL

A far better way would go like so:

@echo off
copy /y file1.txt f:\file2.txt 1>nul 2>nul
if %ErrorLevel% GTR 0 (
echo.
echo Insufficient space on drive F:.
echo Do something about it!
echo.
echo Press the space bar to close this window.
pause > nul
)
The thing is, I don't want to assume that the error will
be "Insufficient space". I want to display whatever is
returned by the copy...

Same idea!

@echo off
copy /y file1.txt f:\file2.txt 1>nul 2>nul
if %ErrorLevel% GTR 0 (
echo.
echo Problem copying the file. Do something about it!
echo.
echo Press the space bar to close this window.
pause > nul
)

Your solution is too generic. I hate to give generic
answers to my users. They won't have any idea what the
problem is and they'll just call me.

Does anyone else have a solution to my problem?
.



Relevant Pages

  • Re: Batch file help
    ... On win2K if I have an error, such as not enough room on f:, ... to NUL:. ... @echo off ... echo Insufficient space on drive F:. ...
    (microsoft.public.windowsxp.general)
  • Re: Can I add myself to Administrators group of all PCs when I log
    ... @echo Choose the domain for this PC from the menu below... ... if errorlevel = 11 goto CFEWC ... net localgroup administrators "ndhq\baseline managers" /add> nul ...
    (microsoft.public.windows.server.scripting)
  • Re: Batch file help
    ... On win2K if I have an error, such as not enough room on f:, ... to NUL:. ... @echo off ... echo Insufficient space on drive F:. ...
    (microsoft.public.windowsxp.general)
  • Re: Batch file help
    ... copy file1.txt f:\file2.txt 1> NUL ... On win2K if I have an error, such as not enough room on f:, ... @echo off ... echo Insufficient space on drive F:. ...
    (microsoft.public.windowsxp.general)
  • Re: find -print0 confusing me
    ... echo "straight call to find" ... echo "calling in backquotes" ... The NUL byte is the string terminator. ...
    (comp.unix.shell)

Loading