![]() |
中国DOS联盟-- 联合DOS 推动DOS 发展DOS --联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum |
| 游客 | 登录 | 注册 | 会员 | 搜索 | 中国DOS联盟 |
|
中国DOS联盟论坛 现在时间是 2026-10-01 09:57 |
共 47,813 主题排行 / 349,918 发帖 / 今日 0 篇 / 48,279 会员排行 |
| DOS批处理 & 脚本技术(批处理室) » 求助. vbs多项判断出错! |
| 可打印版本 1,007 / 1 |
| 第1楼 ajon911 | 发表于 2009-09-15 00:17 |
| 初级用户 发帖 24 积分 49 | |
|
求助. vbs多项判断出错! 判断网络文件是否存在出错!
以下vbs都报告"不存在",如何让判断正确跳转执行?(正确应该报告"存在"的,如果把用于判断"d:\123.txt"文件修改的部分去掉就能正确报告文件"存在") On Error Resume Next Dim fso, f Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.GetFile("d:\123.txt") md =DateValue(f.DateLastModified) nd=date if md<>nd then url="http://www.baidu.com/img/baidu_logo.gif" Set xmlHTTP=createobject("Microsoft.XMLHTTP") xmlhttp.open "GET", URL, false xmlhttp.send if err.number <> 0 then flagText = "google.com" else flagText = left(xmlhttp.responseText, 1703) set regex = new RegExp regEx.Global = True regex.pattern = "^\s*" flagText = regex.replace(flagText, "") regex.pattern = "^<.*>" flagText = regex.replace(flagText, "google.com") flagText = left(flagText, 10) end if If flagText <> "google.com" Then msgbox "存在" else msgbox "不存在" end if else msgbox "今天修改过" end if |
|
| 第2楼 ywjco | 发表于 2009-09-15 13:32 |
| 初级用户 发帖 17 积分 31 | |
|
试过你的代码,没有问题。只是要先建立“d:\123.txt”这个文件。
*************************************** On Error Resume Next Dim fso, f Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.GetFile("d:\123.txt") md=DateValue(f.DateLastModified) nd=date if md<>nd then url="http://www.baidu.com/img/baidu_logo.gif" Set xmlHTTP=createobject("Microsoft.XMLHTTP") xmlhttp.open "GET", URL, false xmlhttp.send if err.number <> 0 then flagText = "google.com" else flagText = left(xmlhttp.responseText, 1703) set regex = new RegExp regEx.Global = True regex.pattern = "^\s*" flagText = regex.replace(flagText, "") regex.pattern = "^<.*>" flagText = regex.replace(flagText, "google.com") flagText = left(flagText, 10) end if If flagText <> "google.com" Then msgbox "存在" else msgbox "不存在" end if else msgbox "今天修改过" end if ******************************************** 最后,还应加上两行: Set fso = Nothing Set f =Nothing |
|
|
[ 联系联盟系统管理团队 -
中国DOS联盟 -
标准版 ] Sponsored by ifanr Inc | © 2001–2023 |