使用VBS创建日志

时间:2013-11-25 12:56:02

标签: logging vbscript

我目前有以下脚本将某个文件夹复制到computers.txt中的每台计算机。虽然它会跳过明显关闭的计算机,但我想知道哪些计算机已被跳过或至少计算机成功。

InputFile = "c:\scripts\input\computers.Txt"
Const OverWriteFiles = True
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(InputFile)
Do While Not (objFile.AtEndOfStream)
strComputer = objFile.ReadLine
On Error Resume Next
objFSO.CopyFolder "\\baardrob\Software\PACS Beheer Tools\PACS Beheer Tools" , "\\" & strComputer & "\c$\PACS Beheer Tools\Pacs starten" , OverWriteFiles
Err.Clear
Loop

MsgBox "Done" 

1 个答案:

答案 0 :(得分:0)

这样的事情应该做:

Set myLog = objFSO.OpenTextFile("C:\path\to\my.log", 2)
Do Until objFile.AtEndOfStream
  strComputer = objFile.ReadLine
  On Error Resume Next
  objFSO.CopyFolder ...
  If Err Then myLog.WriteLine strComputer & vbTab & Err.Number & vbTab _
    & Err.Description
  On Error Goto 0
Loop
myLog.Close