windows bat knowledge

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.
This link: https://blog.csdn.net/include_heqile/article/details/100515840

The output stored in the variable cmd

Use forto 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, %%kit is stored in the process called cmd.exethe number of processes, and it can use set /amathematical 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

Guess you like

Origin blog.csdn.net/include_heqile/article/details/100515840