|
024024
初级用户
 
积分 60
发帖 14
注册 2006-3-23
状态 离线
|
『楼 主』:
[已结]开关用的BAT文件.
使用 LLM 解释/回答一下
开关用的BAT文件.
做一BAT文件,用来打开或者关闭AAA.exe文件.
先用tlist判断进程中是否有AAA.exe文件.
如果没有这进程,则要打开该进程.
如果有这进程,则要杀死这进程.怎样实现?
我用了if,可是我不和怎样判内存是否有这进程.
Last edited by willsort on 2006-6-11 at 19:31 ]
A BAT file for switching the AAA.exe file on or off.
Make a BAT file to open or close the AAA.exe file.
First use tlist to judge whether there is the AAA.exe file in the process.
If there is no this process, then it is necessary to open this process.
If there is this process, then it is necessary to kill this process. How to implement?
I used if, but I don't know how to judge whether there is this process in memory.
Last edited by willsort on 2006-6-11 at 19:31 ]
|
|
2006-5-12 17:27 |
|
|
024024
初级用户
 
积分 60
发帖 14
注册 2006-3-23
状态 离线
|
|
2006-5-15 08:13 |
|
|
fan927
初级用户
 
积分 82
发帖 31
注册 2006-5-23
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
tasklist|find "QQ.exe">1.txt
type 1.txt|find "QQ.exe" && taskkill /f /im qq.exe||start D:\Tencent\QQ\qq.exe
del 1.txt
将"qq.exe"替换为你的程序.
tasklist|find "QQ.exe" > 1.txt
type 1.txt|find "QQ.exe" && taskkill /f /im qq.exe || start D:\Tencent\QQ\qq.exe
del 1.txt
Replace "qq.exe" with your program.
|
|
2006-5-23 00:35 |
|
|
willsort
元老会员
         Batchinger
积分 4432
发帖 1512
注册 2002-10-18
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
Re fan927:
可以考虑合并为一句:
tasklist|find "QQ.exe">nul && taskkill /f /im qq.exe || start D:\Tencent\QQ\qq.exe
关于 fan927 的回复:
可以考虑合并为一句:
tasklist|find "QQ.exe">nul && taskkill /f /im qq.exe || start D:\Tencent\QQ\qq.exe
About fan927:
It can be considered to combine into one sentence:
tasklist|find "QQ.exe">nul && taskkill /f /im qq.exe || start D:\Tencent\QQ\qq.exe
|

※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得! |
|
2006-5-23 01:55 |
|
|
fan927
初级用户
 
积分 82
发帖 31
注册 2006-5-23
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
是啊,确实画蛇添足了.
Yes, it's indeed adding unnecessary details.
|
|
2006-5-23 07:21 |
|
|
kingljp
初级用户
 
积分 80
发帖 29
注册 2006-5-3
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
Originally posted by willsort at 2006-5-23 01:55:
Re fan927:
可以考虑合并为一句:
tasklist|find "QQ.exe">nul && taskkill /f /im qq.exe || start D:\Tencent\QQ\qq.exe
如果我这样用:
:A
tasklist|find "QQ.exe“ || shutdown -l -f -t 10(没有这个程序就注销)
???? (如果有这个程序就延时5分钟,再回到:A。该什么写)
```
Originally posted by willsort at 2006-5-23 01:55:
Re fan927:
Can consider combining into one sentence:
tasklist|find "QQ.exe">nul && taskkill /f /im qq.exe || start D:\Tencent\QQ\qq.exe
If I use it like this:
:A
tasklist|find "QQ.exe" || shutdown -l -f -t 10 (Log off if this program doesn't exist)
???? (If this program exists, delay for 5 minutes and then return to :A. How to write this)
```
|
|
2006-5-24 11:07 |
|
|
fan927
初级用户
 
积分 82
发帖 31
注册 2006-5-23
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
A:
tasklist|find "QQ.exe“ &&ping 1.1.1.1 -n 1 -l 1 -w 300000&&goto A|| shutdown -l -f -t 10
\\ tasklist|find "QQ.exe“如果成功,就ping 1.1.1.1 这个无法ping通的ip来延时,延时完成后,再返回A:
ping 1.1.1.1 -n 1 -l 1 -w 300000,我用抓包工具测试过,在300秒内只会产生一个64字节的icmp包,对网络的影响可以忽略不计.
Last edited by fan927 on 2006-5-26 at 06:20 ]
A:
tasklist|find "QQ.exe" &&ping 1.1.1.1 -n 1 -l 1 -w 300000&&goto A|| shutdown -l -f -t 10
\\ If tasklist|find "QQ.exe" is successful, then ping the unreachable IP 1.1.1.1 to delay. After the delay is completed, return to A:
ping 1.1.1.1 -n 1 -l 1 -w 300000, I have tested with a packet capture tool, and within 300 seconds, only one 64-byte ICMP packet will be generated, and the impact on the network can be ignored.
Last edited by fan927 on 2006-5-26 at 06:20 ]
|
|
2006-5-26 05:56 |
|
|
vlq5299
初级用户
 
积分 136
发帖 59
注册 2006-6-2
状态 离线
|
|
2006-6-11 17:54 |
|
|
yszy
初级用户
 
积分 45
发帖 15
注册 2006-6-18
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
2000 系统的话怎么实现哦``?
How to implement it with the 2000 system?
|
|
2006-6-18 06:11 |
|
|
fudongliu
新手上路

积分 2
发帖 1
注册 2006-6-26 来自 shanghai
状态 离线
|
|
2006-6-26 19:08 |
|
|
liyinsuo
新手上路

积分 2
发帖 1
注册 2006-6-7
状态 离线
|
『第 11 楼』:
确实,但是要是我想实现一个循环判断的程序呢?
使用 LLM 解释/回答一下
循环判断程序是否存在内存中,然后作出是否删除的选择,怎么作出循环的命令呢?
How to make a loop command to determine whether a program exists in memory and then make a choice to delete it?
|
|
2006-7-3 10:12 |
|
|
flying008
中级用户
  
积分 245
发帖 103
注册 2006-6-30
状态 离线
|
『第 12 楼』:
使用 LLM 解释/回答一下
tasklist|find "QQ.exe“ &&ping 1.1.1.1 -n 1 -l 1 -w 300000&&goto A|| shutdown -l -f -t 10
受教了……谢谢楼上的大虾,有两个问题:
1、延时300000后面的"||"和"&&"这2个符号各是什么作用?
2、如果想这个带有PING命令的批处理文件在命令行窗口不显示内容,加上@echo off 后怎么还是不行啊?显示ping 1.1.1.1…… 怎么解决?谢谢……
tasklist|find "QQ.exe“ && ping 1.1.1. What are the functions of the "&&" and "||" here: In batch scripting, "&&" is a logical operator. The command before "&&" will be executed first. If that command executes successfully (returns a exit code of 0), then the command after "&&" will be executed. "||" is also a logical operator. The command before "||" will be executed first. If that command fails (returns a non-zero exit code), then the command after "||" will be executed.
For the issue of not hiding the content: To completely hide the output, you can redirect the output. Modify the line with the ping command to something like ping 1.1.1.1 -n 1 -l 1 -w 300000 >nul 2>nul. The ">nul" redirects the standard output to null and "2>nul" redirects the standard error output to null. So the modified line would be ping 1.1.1.1 -n 1 -l 1 -w 300000 >nul 2>nul&&goto A|| shutdown -l -f -t 10受教了……谢谢楼上的大虾,有两个问题:
1、延时300000后面的"&&"和"||"这2个符号各是什么作用?
2、如果想这个带有PING命令的批处理文件在命令行窗口不显示内容,加上@echo off 后怎么还是不行啊?显示ping 1.1.1.1…… 怎么解决?谢谢……
The functions of "&&" and "||" in batch scripting: "&&" means that if the preceding command executes successfully (exit code 0), then the following command will be executed. "||" means that if the preceding command fails (non-zero exit code), then the following command will be executed.
For the issue of not hiding the output: To make the ping command's output not display, you can redirect the standard output and standard error. Modify the ping command line to ping 1.1.1.1 -n 1 -l 1 -w 300000 >nul 2>nul, so the line becomes ping 1.1.1.1 -n 1 -l 1 -w 300000 >nul 2>nul&&goto A|| shutdown -l -f -t 10
### Translation
tasklist|find "QQ.exe“ &&ping 1.1.1.1 -n 1 -l 1 -w 300000&&goto A|| shutdown -l -f -t 10
Got it... Thank you, senior. There are two questions:
1. What are the functions of the two symbols "&&" and "||" after the delay of 300000?
2. If you want this batch file with the PING command to not display content in the command line window, why does it still not work after adding @echo off? It shows ping 1.1.1.1…… How to solve it? Thank you……
In batch scripting, the role of "&&": If the previous command executes successfully (exit code 0), then the subsequent command will be executed. The role of "||": If the previous command fails (non-zero exit code), then the subsequent command will be executed.
For the issue of not hiding the content: To completely hide the output, you can redirect the output. Modify the line with the ping command to something like ping 1.1.1.1 -n 1 -l 1 -w 300000 >nul 2>nul. The ">nul" redirects the standard output to null, and "2>nul" redirects the standard error output to null. So the modified line would be ping 1.1.1.1 -n 1 -l 1 -w 300000 >nul 2>nul&&goto A|| shutdown -l -f -t 10
tasklist|find "QQ.exe“ && ping 1.1.1.1 -n 1 -l 1 -w 300000&& goto A|| shutdown -l -f -t 10
Got it... Thanks, senior. There are two questions:
1. What are the functions of the two symbols "&&" and "||" after the delay of 300000?
2. If you want this batch file with the PING command to not display content in the command line window, why does it still not work after adding @echo off? It shows ping 1.1.1.1…… How to solve it? Thanks……
In batch scripting, for "&&": If the preceding command executes successfully (exit code 0), the following command is executed. For "||": If the preceding command fails (non-zero exit code), the following command is executed.
For the issue of not hiding the output: To make the ping command's output not display, you can redirect the standard output and standard error. Modify the ping command line to ping 1.1.1.1 -n 1 -l 1 -w 300000 >nul 2>nul, so the line becomes ping 1.1.1.1 -n 1 -l 1 -w 300000 >nul 2>nul&& goto A|| shutdown -l -f -t 10
|
|
2006-7-11 14:14 |
|