![]() |
中国DOS联盟-- 联合DOS 推动DOS 发展DOS --联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum |
| 游客 | 登录 | 注册 | 会员 | 搜索 | 中国DOS联盟 |
|
中国DOS联盟论坛 现在时间是 2026-08-07 14:39 |
共 48,040 主题排行 / 350,125 发帖 / 今日 0 篇 / 48,252 会员排行 |
| DOS批处理 & 脚本技术(批处理室) » 一个关于<Ctrl-Z>自动建立的问题~ |
| 可打印版本 729 / 3 |
| 第1楼 magicroller | 发表于 2008-02-22 12:46 |
| 新手上路 发帖 4 积分 10 来自 安徽 | |
|
一个关于<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> 可是我怎么也创建不起来。 请大侠们将知道的告诉我,我将不胜感激,因为我对批处理也很热爱~ |
|
| 第2楼 magicroller | 发表于 2008-02-24 12:28 |
| 新手上路 发帖 4 积分 10 来自 安徽 | |
|
难道Ctrl+Z无法实现吗? 也许我表述的不好,
我的意思是, 当用 copy con 将数据送如一个文件,最后要用键盘的 Ctrl+Z来保存, 我向将Ctrl+Z放如批处理中,代替我用键盘敲上Ctrl+Z 让他自动的保存,这就是我的目的, 希望高手们能告诉我关于这个想法的可行性! |
|
| 第3楼 slore | 发表于 2008-02-24 14:06 |
| 铂金会员 发帖 2,478 积分 5,212 | |
|
copy con后要自己输入的吧?你BAT下面的内容写不进去。。。
|
|
| 第4楼 523066680 | 发表于 2008-02-24 14:15 |
| 银牌会员 发帖 1,133 积分 2,362 | |
|
不知道vbs发送键值行不?
|
|
|
[ 联系联盟系统管理团队 -
中国DOS联盟 -
标准版 ] Sponsored by ifanr Inc | © 2001–2023 |