Windows batch脚本总结
来源:互联网 发布:中南民族大学网络教育 编辑:程序博客网 时间:2024/05/16 14:28
不得不说Windows batch脚本是我见过的最差劲的脚本,没有之一。
先上一段最近解决的几个小问题的demo代码,包括:
1,赋值变量为其他进程的输出
2,For循环语句计算数列
3,For循环拆分字符串
4,For循环处理文件
5,For循环处理进程输出
@echo offsetlocal enabledelayedexpansion:: set a variable using the output of processtasklist | findstr "explorer.exe" > result.txtset /p FF=<result.txtecho %FF%:: for statement in numbersset total=0for /l %%i in (1,1,5) do (set a=%%iecho !a!set /a total=!total! + !a!)echo total=%total%:: for statement in stringsfor /f "tokens=1,2* delims=_" %%i in ("test_argument_12345") do ( echo %%i echo %%j echo %%k):: for statement using wildcard, shouldn't use /f optionfor %%G in (*.bat *.txt) do echo %%G:: for statement in filesfor /f "tokens=1,2*" %%i in (result.txt) do (set ti=%%iecho !ti!echo %%jecho %%k):: for statement with command outputfor /f "tokens=1,2*" %%i in ('"tasklist | findstr "explorer.exe""') do (set ti=%%iecho !ti!echo %%jecho %%k)endlocal
0 0
- Windows batch脚本总结
- Windows batch脚本常用命令总结
- Oracle Dump windows batch脚本
- windows脚本-CMD和Batch
- Batch script in windows(批处理脚本)
- windows 批处理脚本(batch scripting)
- windows batch脚本中嵌入python程序
- Windows下Batch脚本传递参数给Excel VBA
- windows bat脚本总结
- Windows脚本符号总结
- [windows]如何在batch脚本中检测系统是否安装了python和pip
- Programming Windows Batch Script
- Batch Programming on Windows
- 深入浅出Windows BATCH
- 深入浅出Windows BATCH
- 深入浅出Windows BATCH
- Windows Batch [精华]
- windows batch 常用命令
- 夏华 与“神”交流
- 2014北大软工夏令营机试 B:Number Steps
- atitit.提升开发效率---MDA 软件开发方式的革命(5)----列表查询建模
- JNI编程中关于二维数组编程
- 媒体为什么不多关注下“超强台风'威马逊'”重创海南岛???
- Windows batch脚本总结
- android平台的基础——Dalvik 虚拟机
- 聊聊Service(二)
- 一切从现在开始
- Firefox 里的 Vim(转)
- HDU2602 Bone Collector 【01背包】
- 自动生成android动画配置文件
- Codeforces #257 (Div. 2) C. Jzzhu and Chocolate
- 台风“威马逊”重创广东海南等地