计划任务执行不成功 是否因为文件正在被访问 拒绝写入?

cckakaok cckakaok 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
Dim Html 
dim Url
Url="http://www.***.com/c.asp"
Html = getHTTPPage(Url)
Writefile "D:\wwwroot\index.htm",Html,"UTF-8"

'获取某个地址的html代码
'url:网页地址
Function getHTTPPage(Url)
Dim Http
Set Http=createobject("MSXML2.XMLHTTP")
Http.open "GET",Url,False
Http.send()
If Http.readystate <> 4 Then
Exit Function
End If
getHTTPPage=bytesToBSTR(Http.responseBody,"UTF-8")

Set http = Nothing
If err.number <> 0 Then err.Clear
End Function

Function BytesToBstr(body,Cset)
Dim objstream
Set objstream = CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = Cset
BytesToBstr = objstream.ReadText
objstream.Close
Set objstream = Nothing
End Function

'保存文件
'fileurl:要保存到的地址
'WriteHtml:要保存的内容
Function Writefile(fileurl,WriteHtml,Cset)
Set o_strm = CreateObject("ADODB.Stream")
With o_strm
.Type = 2
.Open
.Charset = Cset
.Position = o_strm.Size
.WriteText = WriteHtml
.SaveToFile fileurl,2
.Close
End With
Set o_strm = Nothing
End Function


index.htm被用户在访问,计划任务执行VBS的时候不成功。提示ADODB.Stream在写文件时因文件被占用而出错
...全文

相关推荐

评论 3
收藏 已收藏
分享
返回顶部
cckakaok
ASP 28,401 成员 356,940 内容