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-06-25 09:15
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » (resolved) How to use a batch file to write ">nul" into a file View 1,991 Replies 7
Original Poster Posted 2002-10-28 00:00 ·  中国 河北 唐山 联通
初级用户
Credits 105
Posts 1
Joined 2002-10-28 00:00
23-year member
UID 87
Gender Male
Status Offline
I want to create a batch file that can do writing, and write characters like ">""nul" into AUTOEXEC.BAT

For example, I want to write del 123.456>nul into AUTOEXEC.BAT
But I found that when I write echo del 123.456>nul>autoexec.bat
what gets written into autoexec is only del 123.456
and the following ">nul" is gone. What's going on?

How can I use a batch file to write characters like ">nul" into another file?
Thanks!!!!

---------- Edited by willsort ----------
Original title changed to: Batch file question
---------- Edited by willsort ----------


[ Last edited by willsort on 2005-10-14 at 13:41 ]
Floor 2 Posted 2002-10-28 00:00 ·  中国 江西 吉安 电信
高级用户
★★
Credits 667
Posts 135
Joined 2002-10-25 00:00
23-year member
UID 62
Gender Male
Status Offline
Man, can't you just honestly use edit to edit the batch file? If you use edit you won't have this headache. Because >NUL is also a special use of the redirection operator under DOS, DOS won't know that this is a character you want to write rather than a redirection operator. In fact DOS will treat it as a redirection operator, and thus interpret it as the command being executed directly. Naturally it won't be treated as characters and redirected into autoexec.bat anymore.
================================= kickout
大功告成,打个Kiss!
Floor 3 Posted 2002-10-28 00:00 ·  美国 肯塔基州 费耶特县 列克星敦 Charter_Communications
系统支持
★★★★★★
“新DOS时代”站长
Credits 27,736
Posts 10,521
Joined 2002-10-09 12:00
23-year member
UID 9
Status Offline
You can use an ECHO enhancement tool to accomplish this. It can be found in the site's "script tools":
http://www.cn-dos.net/newdos/doswaren.html
Wengier - 新DOS时代

欢迎大家来到我的“新DOS时代”网站,里面有各类DOS软件和资料,地址:
http://wendos.mycool.net/

E-Mail & MSN: wengierwu AT hotmail.com (最近比较忙,有事请联系DOSroot和雨露,谢谢!)

Floor 4 Posted 2002-12-01 00:00 ·  中国 辽宁 大连 联通
初级用户
Credits 140
Posts 14
Joined 2002-11-11 00:00
23-year member
UID 220
Gender Male
Status Offline
You did that on purpose, right!
Floor 5 Posted 2003-11-15 00:00 ·  中国 山东 烟台 联通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
Re AAAAAAA:

A simple method, suitable for DOS6.22:

%comspec% /c prompt del 123.456$gnul>autoexec.bat

Similar input includes:

$l less-than sign
$p pipe symbol

[ Last edited by willsort on 2005-10-14 at 13:39 ]
※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 6 Posted 2003-11-18 00:00 ·  中国 河南 安阳 联通
银牌会员
★★★
Credits 1,186
Posts 334
Joined 2003-05-30 00:00
23-year member
UID 2626
Gender Male
Status Offline
Write it like this

Overwrite autoexec.bat
echo del 123.456 >autoexec.bat

Append del 123.456 to the end of autoexec.bat
echo del 123.456 >>autoexec.bat
Floor 7 Posted 2006-06-28 14:31 ·  中国 四川 成都 联通
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
Use echo ^>nul >somebat.bat

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 8 Posted 2006-06-30 09:19 ·  中国 河南 郑州 电信
中级用户
Credits 207
Posts 41
Joined 2004-10-24 00:00
21-year member
UID 32885
Gender Male
Status Offline
Forum Jump: