本帖最后由 Nsqs 于 2016-4-28 01:05 编辑
- dim fso,Wsc,WshPath,s(1),check(1)
- set fso=CreateObject("scripting.filesystemobject")
- Set Wsc=CreateObject("wscript.shell")
- WshPath=Fso.getparentfoldername(wsh.scriptfullname):Wsc.CurrentDirectory = WshPath
- file="2.txt"
- if not fso.fileexists(file) then wsh.quit
- sample="new_"&file
- if not fso.fileexists(sample) then fso.copyfile file,sample
- result=fso.opentextfile(sample).readall
- '正在处理,可能需要点时间...
- t=timer
- s(0)="//#define RADIO_IP31 /* IP31 radio */":s(1)="//#define RADIO_SK81 /* SK81 radio */"
- check(0)=instr(result,s(0))>0:check(1)=instr(result,s(1))>0
- if check(0)=-1 then _
- result=Replace(result,s(0),right(s(0),len(s(0))-2)):_
- result=Replace(result,right(s(1),len(s(1))-2),s(1)):_
- write
- if check(1)=-1 then _
- result=Replace(result,right(s(0),len(s(0))-2),s(0)):_
- result=Replace(result,s(1),right(s(1),len(s(1))-2)):_
- write
- sub write
- fso.createtextfile(sample).write result
- set fso=nothing
- msgbox Round(timer-t,2) & "秒完成!",64
- wsh.quit
- end sub
复制代码 保存vbs代码 |