windows 常用bat脚本

通过windows快速查询当前网段的存活主机

在linux当中查看当前网段存活的主机,通过nmap可以很简单的实现,在windows也可以通过namp实现,但是还要下载nmap,namp又是位于国外网站,下载起来比较慢,其实我们可以通过命令提示符实现,非常简单。

for /L %i IN (1,1,254) DO ping -w 2 -n 1 192.168.1.%i
arp -a

通过nmap扫描

要提前下载nmap(官网下载即可)

C:\Users\zw0132>nmap -sn -PE 192.168.0.0/24

删除三天的文件,搭配定时任务

@echo off
set srcDir="E:\test"
set daysAgo=3
forfiles /p %srcDir% /s /m *.* /d -%daysAgo% /c "cmd /c del @path"

定时rar打包

set Path=;"C:\Program Files\WinRAR";%SystemRoot%\system32
forfiles /p "d:\wxsite" /c "cmd /c WinRAR a -afrar -ep1 -df  backup.zip *.txt"
rename D:\wxsite\backup.zip "%date:~0,4%%date:~5,2%%date:~8,2%.zip"
set Path=;"C:\Program Files\WinRAR";%SystemRoot%\system32
posted @ 2020-07-30 10:19  张贺贺呀  阅读(950)  评论(0编辑  收藏  举报