[工作笔记]几个常用的字符串处理脚本, 标记一下.
//从abc;bdcd;sdf;sefs字符串中分别获取abc bdcd sdf sefs等字符串
//从abc;bdcd;sdf;sefs字符串中分别获取abc bdcd sdf sefs等字符串 for %%i in (%path%) do ( set tmpStr=%%i echo !tmpStr! )
//以上方法无法修改Path, 2K3下可测修改Path的方式
@echo off ::==========>>>添加/删除系统Path变量的指定内容<<<========== ::开启延时加载 setlocal enabledelayedexpansion set pathContent=%1 set opType=%2 ::echo !pathContent! :: ::echo PATH=%path% if not "!pathContent!"=="" ( set tmpStr= set pathStr= for %%i in (%path%) do ( set tmpStr=%%i if {!tmpStr!} NEQ {!pathContent!} ( set pathStr=!pathStr!!tmpStr!; ) if {!opType!}=={/add} ( set pathStr=!pathStr!!pathContent!; ) ) set pathStr=!pathStr:~0,-1! ::WMIC首次使用会占用一定的初始化时间, 以下会永久改变path %windir%\system32\wbem\wmic ENVIRONMENT where "name='path' and username='<system>'" set VariableValue="!pathStr!" ::以下这个只能临时改变Path,不能永久改变 set path="!pathStr!" ) exit /b