|
horser
新手上路

积分 8
发帖 2
注册 2006-8-2
状态 离线
|
『楼 主』:
如何实现30秒间隔循环执行一个批处理文件??
使用 LLM 解释/回答一下
想做一个自动批处理文件,每隔30S 自动循环执行,请问如何实现?
原来想用FOR循环方式的话,该调用什么命令???想了一上午,实在搞不定啊
谢谢!
Last edited by horser on 2006-8-2 at 15:27 ]
Want to make an automatic batch file that executes cyclically every 30 seconds. How to achieve it? Originally, if I want to use the FOR loop method, which command should I call??? I've been thinking about it for a whole morning, really can't figure it out. Thanks!
Last edited by horser on 2006-8-2 at 15:27 ]
|
|
2006-8-2 15:23 |
|
|
namejm
荣誉版主
       batch fan
积分 5226
发帖 1737
注册 2006-3-10 来自 成都
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
以下代码尚未设置终止循环的语句,请自行设置。
@echo off
:loop
do something
ping 127.1 -n 30 >nul 2>nul
goto loop
The following code has not set the statement to terminate the loop, please set it yourself.
@echo off
:loop
do something
ping 127.1 -n 30 >nul 2>nul
goto loop
|

尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。 |
|
2006-8-2 15:38 |
|
|
horser
新手上路

积分 8
发帖 2
注册 2006-8-2
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
多谢!
但是有点不理解,这个“ >nul 2>nul” 是什么意思呢?
Thanks! But I don't quite understand what " >nul 2>nul" means?
|
|
2006-8-2 15:56 |
|
|
IceCrack
中级用户
   DOS之友
积分 332
发帖 168
注册 2005-10-6 来自 天涯
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
hh.exe ntcmds.chm::/redirection.htm
开始 运行. 看看上面的页面就清楚了
hh.exe ntcmds.chm::/redirection.htm
Start Run. Just take a look at the above page to clear it up
|

测试环境: windows xp pro sp2 高手是这样炼成的:C:\WINDOWS\Help\ntcmds.chm |
|
2006-8-2 21:09 |
|
|
namejm
荣誉版主
       batch fan
积分 5226
发帖 1737
注册 2006-3-10 来自 成都
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
Re horser:
>nul 2>nul意思是无论该语句执行是否成功,都屏蔽执行结果在屏幕上的显示。更多的内容,请用论坛的搜索功能。其实这个话题已经有很多的帖子涉及过了,善用论坛的搜索功能会让你很快成为批处理高手的。
Re horser:
>nul 2>nul means that regardless of whether the execution of this statement is successful or not, the display of the execution result on the screen is blocked. For more content, please use the search function of the forum. In fact, this topic has been involved in many posts, and making good use of the search function of the forum will make you quickly become a batch processing expert.
|

尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。 |
|
2006-8-2 23:36 |
|
|
xjmxjm1234
中级用户
   论坛第一菜鸟
积分 361
发帖 166
注册 2006-4-15
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
nul 是空设备名 像个黑洞
> 是覆盖输出的意思
1是输出流,2是错误流(1可以省略不写)
>nul 2>nul 就是把 命令执行的输出信息和错误信息不输出到屏幕,而是输出到一个根本不存在的设备.
常见设备名:
con 控制台(键盘和显示器)
aux , com1 - com4 所有串口
prn , lpt1 - lpt3 所有并口
nul 空设备
clock$ 电子钟
写命令时可以引用,文件不能用这些名字来命名
重定向操作符
> 将命令输出写入到文件或设备中,而不是写在命令提示符窗口中。
< 从文件中而不是从键盘中读入命令输入。
>> 将命令输出添加到文件末尾而不删除文件中的信息。
>& 将一个句柄的输出写入到另一个句柄的输入中。
<& 从一个句柄读取输入并将其写入到另一个句柄输出中。
| 从一个命令中读取输出并将其写入另一个命令的输入中。也称作管道。
0 输入
1 输出
2 错误输出
3-9 由应用程序和各个具体工具单独定义。
nul is an empty device name, like a black hole.
> means to overwrite the output.
1 is the output stream, 2 is the error stream (1 can be omitted without writing).
>nul 2>nul means to not output the output information and error information of the command execution to the screen, but to an equipment that does not exist at all.
Common device names:
con console (keyboard and display)
aux, com1 - com4 all serial ports
prn, lpt1 - lpt3 all parallel ports
nul empty device
clock$ electronic clock
Can be referenced when writing commands, and files cannot be named with these names.
Redirection operators
> Write the command output to a file or device instead of writing it in the command prompt window.
< Read command input from a file instead of from the keyboard.
>> Add the command output to the end of the file without deleting the information in the file.
>& Write the output of one handle to the input of another handle.
<& Read input from one handle and write it to the output of another handle.
| Read output from one command and write it to the input of another command. Also called a pipeline.
0 input
1 output
2 error output
3-9 are individually defined by applications and various specific tools.
|

Diskette Operating System |
|
2006-8-3 13:53 |
|
|
studyit
新手上路

积分 2
发帖 1
注册 2006-8-7
状态 离线
|
『第 7 楼』:
感谢六楼
使用 LLM 解释/回答一下
xjmxjm1234的指点让我全明白了以前不明白几个的符号。
非常感谢
The guidance from xjmxjm1234 has made me fully understand the symbols that I didn't understand before. Thank you very much
|
|
2006-8-7 22:53 |
|
|
luowei14
初级用户
 
积分 193
发帖 98
注册 2007-1-17
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
好帖就得顶。。。。楼主的帖让我领悟了很多东西。。下面这个作品就是拜楼主所赐
每隔20秒自动检测进程列表,自动关闭notepad.exe,也就是记事本程序,如有需要,可以改成某病毒的名称,可以起到监控的作用。。。
@echo off
:1
tasklist | find "notepad.exe" >>c:\notepad.luowei
if exist c:\notepad.luowei taskkill /f /im notepad.exe
ping 127.1 -n 20 >nul 2>nul
goto 1
Last edited by luowei14 on 2007-6-18 at 02:57 PM ]
A good post must be topped... The post by the LZ has made me understand a lot of things. The following work is thanks to the LZ
It automatically checks the process list every 20 seconds and automatically closes notepad.exe, which is the Notepad program. If needed, it can be changed to the name of a certain virus, which can play a monitoring role.
@echo off
:1
tasklist | find "notepad.exe" >>c:\notepad.luowei
if exist c:\notepad.luowei taskkill /f /im notepad.exe
ping 127.1 -n 20 >nul 2>nul
goto 1
Last edited by luowei14 on 2007-6-18 at 02:57 PM ]
|

这家伙很聪明 什么都没留下 |
|
2007-6-18 14:55 |
|
|
jzcn
新手上路

积分 16
发帖 8
注册 2007-4-4
状态 离线
|
|
2007-6-20 08:20 |
|