蓝色动力网络

 找回密码
 立即注册

扫一扫,访问微社区

QQ登录

只需一步,快速开始

查看: 4306|回复: 0

VBS对比更新游戏

[复制链接]
发表于 2009-4-4 11:26:10 | 显示全部楼层 |阅读模式
  1.     Option Explicit
  2.     'URL:http://www.ganhui0818.cn
  3.     Dim SDir, LDir, MandatoryUpdate, DelRedundantFile, CompareSubFolder, MandatoryUpdateFolder
  4.     Dim ExcludedFolder, MandatoryUpdateFile, ExcludedFile, DiffTime, RunFile, RegFile, SystemFile
  5.    
  6.     '远程目录
  7.     SDir = "\\gameserver\d\xiuxian\qq2008"
  8.     '本地目录
  9.     LDir = "f:\Documents and Settings\Administrator\桌面\新建文件夹2"
  10.     '是否强制更新所有文件(不对比,直接设所有文件为需更新状态),是=True,否=False,下同
  11.     MandatoryUpdate = False
  12.     '文件差异时间在此值内则不更新(单位:秒),建议设为3秒,强制更新所有文件时,勿略此设置
  13.     DiffTime = 3
  14.    
  15.     Dim sobjFSO
  16.     Set sobjFSO = CreateObject("Scripting.FileSystemObject")
  17.     If Not CheckFolder(SDir,False) Then
  18.         Msgbox "远程目录" & Chr(34) & SDir & Chr(34) & "不存在,请确认!",64,"提示"
  19.         WScript.Quit
  20.     End If
  21.     Dim StartTime
  22.     StartTime = Now
  23.     ShowFolder SDir,LDir,DiffTime,MandatoryUpdate
  24.     Msgbox "耗时:" & Datediff("s",StartTime,Now) & "秒"
  25.    
  26.    
  27. Function CheckFolder(strFolder,blnCreate)
  28.     If Not sobjFSO.FolderExists(sobjFSO.GetDriveName(strFolder)) Then
  29.         CheckFolder = False
  30.         Exit Function
  31.     End If
  32.     If Not sobjFSO.FolderExists(strFolder) And blnCreate Then
  33.         If CheckFolder(sobjFSO.GetParentFolderName(strFolder),blnCreate) Then
  34.             On Error Resume Next
  35.             sobjFSO.CreateFolder strFolder
  36.             If Err Then
  37.                 CheckFolder = False
  38.                 Err.Clear
  39.                 On Error GoTo 0
  40.                 Exit Function
  41.             Else
  42.                 CheckFolder = True
  43.             End If
  44.             On Error GoTo 0
  45.         Else
  46.             CheckFolder = False
  47.         End If
  48.     Elseif Not sobjFSO.FolderExists(strFolder) And Not blnCreate Then
  49.         CheckFolder = False
  50.     Else
  51.         CheckFolder = True
  52.     End If
  53. End Function
  54. Function ShowFolder(Folder1,Folder2,intTimes,blnMandatory)
  55.     Dim objF, objFLs, objFL
  56.     Set objF = sobjFSO.GetFolder(Folder1)
  57.     Set objFLs = objF.SubFolders
  58.     ScanFile Folder1,Folder2,intTimes,blnMandatory
  59.     For Each objFL in objFLs
  60.         ShowFolder objFL.Path,Replace(objFL.Path,Folder1,Folder2,1,1,1),intTimes,blnMandatory
  61.     Next
  62. End Function
  63. Function ScanFile(Folder1,Folder2,intTimes,blnMandatory)
  64.     If Not CheckFolder(Folder2,True) Then Exit Function
  65.     Dim objF, objFIs, objFI, objTmpF
  66.     Set objF = sobjFSO.GetFolder(Folder1)
  67.     Set objFIs = objF.Files
  68.     For Each objFI In objFIs
  69.         If Not sobjFSO.FileExists(Replace(objFI.Path,Folder1,Folder2,1,1,1)) or blnMandatory Then
  70.             objFI.Copy Replace(objFI.Path,Folder1,Folder2,1,1,1)
  71.         Else
  72.             Set objTmpF = sobjFSO.GetFile(Replace(objFI.Path,Folder1,Folder2,1,1,1))
  73.             If objFI.Size <> objTmpF.Size or Abs(DateDiff("s",objFI.DateLastModified,objTmpF.DateLastModified)) >= intTimes Then
  74.                 objFI.Copy Replace(objFI.Path,Folder1,Folder2,1,1,1)
  75.             End If
  76.         End If
  77.     Next
  78. End Function
复制代码
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

蓝色动力网络微信平台
网站管理,业务合作联系邮箱: admin#lansedongli.com    QQ:13412492 限网站业务问题.
网站帐号、密码、密保找回请使用注册邮箱,发送邮件至 password#lansedongli.com ,否则不予受理.
免责声明:本论坛所有文字和图片仅代表其个人观点.
本站某些资料或文章来自于互联网,不代表本站观点,如果侵犯了您的权益,请来信告知,我们会在三天内删除.
为了给大家一个更好的交流场所,请勿在本论坛发表与中华人民共和国法律相抵触的言论,请合作,谢谢!
Copyright © 2007-2019 Corporation Powered by网吧系统 版权所有    转载请注明!
浙ICP备11043737号-1 程序:Discuz! x3.4

湘公网安备 43018102000145号

手机版|Archiver|蓝色动力网络   

快速回复 返回顶部 返回列表