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