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

cckakaok 2011-12-14 09:38:11
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在写文件时因文件被占用而出错
...全文
89 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
cckakaok 2011-12-15
  • 打赏
  • 举报
回复
总算有个人回了


没人打开htm文件的时候就可以生成 有人就不行了 使用FSO对象不能生成UTF8啊。
csdn_aspnet 2011-12-15
  • 打赏
  • 举报
回复
看看你有没有权限 或者使用 CreateObject("Scripting.FileSystemObject")对象
cckakaok 2011-12-14
  • 打赏
  • 举报
回复
木有人?

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧