我正在尝试编写一个 VBScript 将日志文件从少数网络计算机备份到网络服务器上的共享驱动器。
这是我目前所拥有的:
Option Explicit
Const OverWriteFiles = True
Dim fso, objShell
Set fso = WScript.CreateObject("Scripting.Filesystemobject")
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim WshNetwork
Set WshNetwork = WScript.CreateObject("WScript.Network")
Dim Computername, regComputerName, nfolder, folderdate, fday, fmonth, fyear
Dim path1, path2, fdate, objFolder
Set objShell = CreateObject("WScript.Shell")
regComputerName = "HKLM\SYSTEM\CurrentControlSet\Control" &_
"\ComputerName\ComputerName\ComputerName"
ComputerName = objShell.RegRead(regComputerName)
fdate = Date()
fday = (Day(fdate))
If Len(fday) < 2 Then
fday = 0 & fday
End If
fmonth = (Month(fdate))
If Len(fmonth) < 2 Then
fmonth = 0 & fmonth
End If
fyear = (Year(fdate))
folderdate = "." & fyear & "_" & fmonth & "_" & fday
nfolder = Computername & folderdate
path1 = "C:\Windows\System32\Winevt\Logs\"
path2 = "Z:\test\"
If objFSO.FolderExists (path2 & nfolder) Then
objFSO.deleteFolder (path2 & nfolder)
Set objFolder = objFSO.CreateFolder (path2 & nfolder)
Else
Set objFolder = objFSO.CreateFolder(path2 & nfolder)
End if
path2 = path2 & nfolder
fso.CopyFolder path1, path2, OverWriteFiles
在调试脚本时,我在最后一行不断收到一条错误,提示“Microsoft VBScript 运行时错误 (42, 1) :未找到路径”
不确定我遗漏了什么。如能提供任何帮助我将不胜感激。