很早之前,有人就问过,帖子如下:
http://www.scmlife.com/bbs/thread-5849-1-1.html
后来我测试了,发现有时候可能脚本不能执行,如果服务器拒绝了请求的话
但是解决问题的途径有很多种,下面我提供另外一种方法,而且是可行的,如下:
在代码中创建WScript.Shell对象
使用该对象的Run方法执行net time,将结果写入到临时文件中,使用FSO解析并读取对应的时间就可以了
如:
Dim aa
Set aa = CreateObject("WScript.Shell")
aa.Run "cmd"
aa.SendKeys "cd \"
aa.SendKeys "{Enter}"
aa.SendKeys "net time \\xx.xx.xx.xx >C:\aatime.txt"
aa.SendKeys "{Enter}"
aa.SendKeys "exit"
aa.SendKeys "{Enter}"
Set aa = Nothing
net time执行后返回的结果如下格式:
Current time at \\xx.xx.xx.xx is 2008/1/8 下午 12:14
The command completed successfully.
[
本帖最后由 yunshan 于 2008-1-8 12:41 编辑 ]