本帖最后由 apang 于 2013-11-11 18:32 编辑
把下面代码保存为test.bat- @set @n=0//&dir /a-d/b/s "%~1"|cscript -nologo -e:jscript "%~f0" "%~2" "%~3" &pause&exit/b
- a = WScript.Arguments(0);
- b = WScript.Arguments(1);
- while (!WSH.StdIn.AtEndOfStream) {
- file = WSH.StdIn.ReadLine();
- fso = new ActiveXObject("Scripting.FileSystemObject");
- re = new RegExp("^( *)" + a + "[^\\r\\n]+","im");
- text = fso.OpenTextFile(file,1).ReadAll();
- text = text.replace(re, "$1" + b);
- fso.OpenTextFile(file,2).Write(text);
- fso = null;
- re = null;
- }
复制代码 然后:- test.bat "tiger.bat" "set tiger" "set tiger=3m arm=1m"
复制代码
|