标题: 一个关于<Ctrl-Z>自动建立的问题~
[打印本页]
作者: magicroller
时间: 2008-2-22 12:46
标题: 一个关于<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>
可是我怎么也创建不起来。
请大侠们将知道的告诉我,我将不胜感激,因为我对批处理也很热爱~
作者: magicroller
时间: 2008-2-24 12:28
标题: 难道Ctrl+Z无法实现吗?
也许我表述的不好,
我的意思是,
当用 copy con 将数据送如一个文件,最后要用键盘的
Ctrl+Z来保存,
我向将Ctrl+Z放如批处理中,代替我用键盘敲上Ctrl+Z
让他自动的保存,这就是我的目的,
希望高手们能告诉我关于这个想法的可行性!
作者: slore
时间: 2008-2-24 14:06
copy con后要自己输入的吧?你BAT下面的内容写不进去。。。
作者: 523066680
时间: 2008-2-24 14:15
不知道vbs发送键值行不?