本帖最后由 lixiaolong 于 2012-3-30 13:33 编辑
回复 1# apoorman1986
修改了一楼代码,有多余的代码去掉了,还有你这个正则有问题.
用你的正则【"(.*?)\\】就变成这样【command.29.*=I:AU3\Au3.REHelper.exe"】.
应该转换成【command.29.*="I:\AU3\Au3.REHelper.exe"】.
$Drive = DriveGetDrive("removable")
If $Drive = 0 Then
MsgBox(0, "提示", "没有插入U盘")
Exit
EndIf
For $i = 1 To $Drive[0]
$s = StringUpper($Drive[$i])
Next
$sfile = $s & "\AU3\SciTe\UserHome\用户设置.properties"
$encoding = FileGetEncoding($sfile)
If $encoding = -1 Then
MsgBox(4096, "错误", "不能获取文件编码.")
Exit
Else
$str = FileRead($sfile)
$sReplace = StringRegExpReplace($str, '(\w:)', $s)
$rfile = FileOpen($sfile, 2 + $encoding)
FileWrite($rfile, $sReplace)
FileClose($rfile)
EndIf
|