Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
The output stored in the variable cmd
Use for
to achieve
@echo off
setlocal ENABLEDELAYEDEXPANSION
for /F %%k in ('tasklist ^| find /i "cmd.exe" /c') do (
echo %%k
set /a var = %%k + 1
echo !var! )
As a result, %%k
it is stored in the process called cmd.exe
the number of processes, and it can use set /a
mathematical operations
Comparison Operators
EQU - 等于
NEQ - 不等于
LSS - 小于
LEQ - 小于或等于
GTR - 大于
GEQ - 大于或等于
Acquisition path
@echo off
echo 当前盘符:%~d0
echo 当前盘符和路径:%~dp0
echo 当前批处理全路径:%~f0
echo 当前盘符和路径的短文件名格式:%~sdp0
echo 当前CMD默认目录:%cd%
echo 当前盘符:”%~d0"
echo 当前盘符和路径:"%~dp0"
echo 当前批处理全路径:"%~f0"
echo 当前盘符和路径的短文件名格式:"%~sdp0"
echo 当前CMD默认目录:"%cd%"
Check whether it exists
@echo off
if not "%1" equ "" (
echo succeed )
* Note that double quotes must be 1%
Nuo induced echo is not an internal or external command, operable program or batch file
Coding problem, bat only supports ANSI, then use Save As to open the notepad