China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-07-31 22:26
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » How to print DOS error messages to a txt file? View 6,475 Replies 18
Floor 16 Posted 2006-05-13 18:36 ·  中国 山西 临汾 中移铁通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
Re regarding:

Regarding the error capture in pure DOS, I mentioned it on the 12th route. Here I restate two points:

1. DOS has no handles, so it does not support the usage of 1>nul and 2>nul;

2. Almost none of the internal commands in DOS support ERRORLEVEL, so its error status cannot be judged by errorlevel, but other methods must be sought for judgment, such as using alternative external commands (xcopy instead of copy), such as using if exist to judge the existence of the file before and after copy.
※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 17 Posted 2006-05-15 11:42 ·  中国 甘肃 兰州 中移铁通
初级用户
Credits 90
Posts 38
Joined 2006-01-06 18:41
20-year member
UID 48522
Status Offline
Got it, I will be more clear about the distinction between DOS and CMD in the future.
Floor 18 Posted 2009-12-06 00:10 ·  中国 山东 联通
新手上路
Credits 2
Posts 2
Joined 2009-12-01 22:35
16-year member
UID 155759
Gender Male
From 山东
Status Offline
@echo off
copy \1dir\1.ext >3.txt
type 3.txt
pause
Floor 19 Posted 2010-11-21 23:02 ·  中国 甘肃 兰州 红古区 电信
初级用户
Credits 24
Posts 18
Joined 2007-04-01 11:09
19-year member
UID 83611
Gender Male
Status Offline
if exist 1.log goto co
echo File not found!>2.log
type 2.log
del 2.log
pause>nul
exit
:co
copy 1.log \Personal\Desktop\1.txt>2.log
type 2.log
del 1.txt;1.log;2.log
pause>nul
Forum Jump: