清空iis log 中自己登录ip的vbs
程序员文章站
2022-05-18 11:53:44
option explicit
dim sourcefile,ipaddress,objargs
const destfile="tempfile"...
option explicit
dim sourcefile,ipaddress,objargs
const destfile="tempfile"
const forwriting = 2
dim text
dim fso,objnet,serviceobj
dim txtstream, txtstreamout
set objargs = wscript.arguments
if objargs.count = 2 then
sourcefile=objargs(0)
ipaddress=objargs(1)
else
wscript.echo "parameter error"+ vbcrlf
wscript.echo "usage:killlog.vbs logfilename yourip."
wscript.quit 1
end if
set fso = createobject("scripting.filesystemobject")
if fso.fileexists (sourcefile) then
set objnet = wscript.createobject( "wscript.network" )
set serviceobj = getobject("winnt://" & objnet.computername & "/w3svc")
set objnet=nothing
serviceobj.stop
wscript.sleep 6000
set txtstream = fso.opentextfile(sourcefile)
set txtstreamout = fso.opentextfile(destfile, forwriting, true)
do while not (txtstream.atendofstream)
text = txtstream.readline
if instr(text,ipaddress)=0 then
txtstreamout.writeline text
end if
loop
set txtstream = nothing
set txtstreamout = nothing
wscript.echo "the log file-- " & sourcefile &" has cleaned your ip!"
else
wscript.echo "the log file-- " & sourcefile & " has not found!"
wscript.quit
end if
fso.copyfile destfile, sourcefile
fso.deletefile destfile
set fso=nothing
serviceobj.start
set serviceobj = nothing
dim sourcefile,ipaddress,objargs
const destfile="tempfile"
const forwriting = 2
dim text
dim fso,objnet,serviceobj
dim txtstream, txtstreamout
set objargs = wscript.arguments
if objargs.count = 2 then
sourcefile=objargs(0)
ipaddress=objargs(1)
else
wscript.echo "parameter error"+ vbcrlf
wscript.echo "usage:killlog.vbs logfilename yourip."
wscript.quit 1
end if
set fso = createobject("scripting.filesystemobject")
if fso.fileexists (sourcefile) then
set objnet = wscript.createobject( "wscript.network" )
set serviceobj = getobject("winnt://" & objnet.computername & "/w3svc")
set objnet=nothing
serviceobj.stop
wscript.sleep 6000
set txtstream = fso.opentextfile(sourcefile)
set txtstreamout = fso.opentextfile(destfile, forwriting, true)
do while not (txtstream.atendofstream)
text = txtstream.readline
if instr(text,ipaddress)=0 then
txtstreamout.writeline text
end if
loop
set txtstream = nothing
set txtstreamout = nothing
wscript.echo "the log file-- " & sourcefile &" has cleaned your ip!"
else
wscript.echo "the log file-- " & sourcefile & " has not found!"
wscript.quit
end if
fso.copyfile destfile, sourcefile
fso.deletefile destfile
set fso=nothing
serviceobj.start
set serviceobj = nothing
上一篇: 武则天的野心是怎么出现的 她是如此一步步把持朝政的
下一篇: 除了数学题