目录重复新建代码分析
v脚本分析
目录重复创建代码分析,利用goto语句重复进行新建(md)
@echo off
cd F:
set a=0
:loop
set /a a+=1
md V
cd V
if %a%==4 goto end
goto loop
pause>null
exit
计算机信息展示
@echo off
echo. > log.txt
echo log File >>log.txt
echo. >> log.txt
echo User : %username% >> log.txt
date /t >> log.txt
time /t >> log.txt
echo. >>log.txt
echo Process ran by %username% >> log.txt
echo. >>log.txt
tasklist >>log.txt
echo. >>log.txt
echo Network Activities >>log.txt
netstat -s >>log.txt
ipconfig /all >>log.txt
exit
交互操作
跳转语句goto
@echo off
echo 1.a
echo 2.b
echo 3.c
echo 4.d
:first
echo Enter your option:
rem /p是标准数对应的值保存到变量opt
set /p opt=
if %opt% ==1 goto one
if %opt% ==2 goto two
if %opt% ==3 goto three
if %opt% ==4 goto four
rem输入其他数字则返回first
echo Invalid option
goto first
:one
echo your choice one
pause>null
exit
:two
echo your choice two
pause>null
exit
:three
echo your choice three
pause>null
exit
:four
echo your choice four
pause>null
exit
实际应用
@echo off
echo 1.show ip address
echo 2.show network link
echo 3.show direcotory
:main
echo Enter your iption:
set /p opt=
if %opt%==1 goto one
if %opt%==2 goto two
if %opt%==3 goto three
echo Invalid option
goto main
:one
ipconfig /all
pause>null
exit
:two
netstat -an
pause>null
exit
:three
dir
pause>null
exit
计划执行操作
at
@echo off
rem automate Running
at 10:00 AM /everyday:SU,M,TU,W,TH,F,SA "路径bat"
exit
批处理脚本转exe
使用工具 Bat to Exe Converter
不要把转化的软件直接在计算机上使用,最好是虚拟机运行
其他工具自己找一找吧!