| rem 另存为 ANSI 编码 bat | | | | | | PHP_INI_FILE = "php.ini-dist" | | SEARCH_TEXT = "; cgi.fix_pathinfo = 0" | | REPLACE_TEXT = "cgi.fix_pathinfo = 1" | | OUT_FILE = "php.ini" | | | | Set oStream = CreateObject("ADODB.Stream") | | oStream.Type = 2 | | oStream.Mode = 3 | | oStream.Charset = "GBK" | | oStream.Open() | | oStream.LoadFromFile PHP_INI_FILE | | s = oStream.ReadText() | | oStream.Close() | | m = Replace(SEARCH_TEXT, " ", "") | | m = Replace(m, ".", "\.") | | Pattern = "^" | | If Left(m, 1) = ";" Then | | Pattern = Pattern & "; *" | | m = Right(m , Len(m) - 1) | | End If | | m = Split(m, "=") | | Pattern = Pattern & m(0) & " *= *" & m(1) | | Set oRegExp = CreateObject("VBScript.RegExp") | | oRegExp.Global = True | | oRegExp.MultiLine = True | | oRegExp.IgnoreCase = True | | oRegExp.Pattern = Pattern | | If oRegExp.Test(s) Then s = oRegExp.Replace(s, REPLACE_TEXT) | | oStream.Open() | | oStream.WriteText s | | oStream.SaveToFile OUT_FILE, 2 | | oStream.Close()COPY |
不知道5楼的powershell楼主为什么不用,win7、win10、win11都是自带powershell.exe的,很方便
这个是批处理调用cscript.exe,也是winxp、win7、win10、win11自带的命令
这里做了兼容性处理
SEARCH_TEXT指定为以下几行都可以得到同样的结果
; cgi.fix_pathinfo = 0
; cgi.fix_pathinfo = 0
;cgi.fix_pathinfo=0
cgi.fix_pathinfo = 0 |