中国DOS联盟论坛

中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --

联盟域名:www.cn-dos.net  论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!

游客:  注册 | 登录 | 命令行 | 会员 | 搜索 | 上传 | 帮助 »
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » 一个关于<Ctrl-Z>自动建立的问题~
作者:
标题: 一个关于<Ctrl-Z>自动建立的问题~ 上一主题 | 下一主题
magicroller
新手上路




积分 10
发帖 4
注册 2008-2-22
来自 安徽
状态 离线
『楼 主』:  一个关于<Ctrl-Z>自动建立的问题~

在网上看到一个批处理是这样的: --------------------------from a personal e-mail-------------------------- Here's my *pure batch* solution to user input: Note that this batch must be termited with a Ctrl-Z immediately after the last line (no CR/LF !) and that it must be located in C:\ :: :: interactive set command :: :: syntax: xset env_var :: :: one line of user input is :: assigned to the specified :: environment variable :: :: Note: - last line must terminate :: with Ctrl-Z :: - xset.bat must be located in C:\ :: :: (c) Ed Schwartz :: @echo off if %2*==+* goto set echo <Esc>[13;26;13p copy C:\xset.bat+con %temp%\_xset.bat > nul echo <Esc>[13;13p call %temp%\_xset.bat %1 + :set if %2*==+* set %1=<Ctrl-Z> ------------------------------end of quote-------------------------------- It is evident that this method needs ANSI.SYS. The first method uses piping through date, and the second appending to a file that doesn't end on cr/lf, but the difference is cosmetic at best. The reason I include this second batch, is the clever use made of ANSI escape sequences. The second method cannot display a prompt in front of the cursor. There is a way to work around the problem that the batch file has to be situated in a known, constant directory: let the batch look for itself in all directories of the system path + the current directory, with IF EXIST %0.bat. My virus for batch files did something like that to find its own code back. Let this be an inducement to read my earlier work :-) 我想弄明白这个bat中,如何使用<Ctrl-Z>,的用法,请高手们能告诉我一点, 比如我想用批处理 建立一个文本文件,并让它自动保存,当然用>文件定向符 也可以将数据自动的写入一个文件中。如: @echo off copy con 123.txt lh con hello,world if %1==123.txt set %1=<Ctrl-Z> 可是我怎么也创建不起来。 请大侠们将知道的告诉我,我将不胜感激,因为我对批处理也很热爱~


2008-2-22 12:46
查看资料  发送邮件  发短消息 网志  OICQ (334144332)  编辑帖子  回复  引用回复
magicroller
新手上路




积分 10
发帖 4
注册 2008-2-22
来自 安徽
状态 离线
『第 2 楼』:  难道Ctrl+Z无法实现吗?

也许我表述的不好, 我的意思是, 当用 copy con 将数据送如一个文件,最后要用键盘的 Ctrl+Z来保存, 我向将Ctrl+Z放如批处理中,代替我用键盘敲上Ctrl+Z 让他自动的保存,这就是我的目的, 希望高手们能告诉我关于这个想法的可行性!


2008-2-24 12:28
查看资料  发送邮件  发短消息 网志  OICQ (334144332)  编辑帖子  回复  引用回复
slore
铂金会员





积分 5212
发帖 2478
注册 2007-2-8
状态 离线
『第 3 楼』:  

copy con后要自己输入的吧?你BAT下面的内容写不进去。。。


2008-2-24 14:06
查看资料  发短消息 网志   编辑帖子  回复  引用回复
523066680
银牌会员

SuperCleaner


积分 2362
发帖 1133
注册 2008-2-2
状态 离线
『第 4 楼』:  

不知道vbs发送键值行不?


2008-2-24 14:15
查看资料  发送邮件  访问主页  发短消息 网志  OICQ (523066680)  编辑帖子  回复  引用回复

请注意:您目前尚未注册或登录,请您注册登录以使用论坛的各项功能,例如发表和回复帖子等。


可打印版本 | 推荐给朋友 | 订阅主题 | 收藏主题



论坛跳转: