![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-08-01 20:06 |
48,037 topics / 350,122 posts / today 2 new / 48,249 members |
| DOS批处理 & 脚本技术(批处理室) » [Closed] BAT file for switches |
| Printable Version 1,594 / 11 |
| Floor1 024024 | Posted 2006-05-12 17:27 |
| 初级用户 Posts 14 Credits 60 | |
|
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 ] |
|
| Floor2 024024 | Posted 2006-05-15 08:13 |
| 初级用户 Posts 14 Credits 60 | |
|
Can everyone give me some ideas?
|
|
| Floor3 fan927 | Posted 2006-05-23 00:35 |
| 初级用户 Posts 31 Credits 82 | |
|
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. |
|
| Floor4 willsort | Posted 2006-05-23 01:55 |
| 元老会员 Posts 1,512 Credits 4,432 | |
|
关于 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 |
|
| Floor5 fan927 | Posted 2006-05-23 07:21 |
| 初级用户 Posts 31 Credits 82 | |
|
Yes, it's indeed adding unnecessary details.
|
|
| Floor6 kingljp | Posted 2006-05-24 11:07 |
| 初级用户 Posts 29 Credits 80 | |
|
```
Originally posted by willsort at 2006-5-23 01:55: 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) ``` |
|
| Floor7 fan927 | Posted 2006-05-26 05:56 |
| 初级用户 Posts 31 Credits 82 | |
|
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 ] |
|
| Floor8 vlq5299 | Posted 2006-06-11 17:54 |
| 初级用户 Posts 59 Credits 136 | |
|
Learning
|
|
| Floor9 yszy | Posted 2006-06-18 06:11 |
| 初级用户 Posts 15 Credits 45 | |
|
How to implement it with the 2000 system?
|
|
| Floor10 fudongliu | Posted 2006-06-26 19:08 |
| 新手上路 Posts 1 Credits 2 From shanghai | |
| Floor11 liyinsuo | Posted 2006-07-03 10:12 |
| 新手上路 Posts 1 Credits 2 | |
|
How to make a loop command to determine whether a program exists in memory and then make a choice to delete it?
|
|
| Floor12 flying008 | Posted 2006-07-11 14:14 |
| 中级用户 Posts 103 Credits 245 | |
|
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 |
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |