找回密码
 注册
搜索
[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
查看: 14655|回复: 0

[问题求助] 这个“备份打印日志文件”的VBS有问题没?

[复制链接]
发表于 2011-1-18 16:12:25 | 显示全部楼层 |阅读模式
作用,将C:\cshis中的打印日志文件复制到D:\cshisLog目录(因为机器上安装有还原精灵,C:盘冻结了,所以写了这个代码,每5分钟判断一次,如果日志文件有更新,就复制)
  1. while 1
  2. wscript.sleep 5000
  3. dim fso,strcsPath,strbackPath,cshisFolder,csBackFolder,fileName
  4. set fso =CreateObject("Scripting.FileSystemObject")
  5. strcsPath="C:\cshis"
  6. strbackPath="D:\cshisLog"
  7. if fso.FolderExists(strcsPath) then
  8. set cshisFolder=fso.GetFolder(strcsPath)
  9. else wscript.Quit
  10. end if
  11. if not fso.FolderExists(strbackPath) then
  12. fso.CreateFolder(strbackPath)
  13. end if
  14. if not fso.FolderExists(strbackPath) then
  15. msgbox strbackPath+" 目录没有创建成功"
  16. wscript.Quit '退出所有vbs执行语句
  17. else
  18. set csBackFolder=fso.GetFolder(strbackPath)
  19. end if

  20. for each file in cshisFolder.Files
  21. if Instr(file.Name,"printserverrec") > 0 then
  22. backfilepath=csBackFolder.path+""+file.Name
  23. if fso.FileExists(backfilepath) then
  24. dim backFile
  25. set backFile= fso.GetFile(backfilepath)
  26. if backFile.DateCreated - file.DateCreated then
  27. 'file.Copy(backfilepath) 不需要做这个操作了。。。
  28. elseif backFile.DateLastModified - file.DateLastModified then '不等于
  29. file.Copy(backfilepath)
  30. end if
  31. set backFile=nothing
  32. else file.Copy(backfilepath)
  33. end if
  34. end if
  35. next
  36. set fso=nothing
  37. set strcsPath=nothing
  38. set strbackPath=nothing
  39. set cshisFolder=nothing
  40. set csBackFolder=nothing
  41. set fileName=nothing

  42. wend
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|批处理之家 ( 渝ICP备10000708号 )

GMT+8, 2026-3-17 11:31 , Processed in 0.016438 second(s), 8 queries , File On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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