이벤트 로그를 보관하도록 VB 스크립트를 수정하는 방법은 무엇입니까? 나는 found one VB script 네트워크 공유 폴더로 이벤트 로그를 보관하는 것이 잘 작동,하지만 난에 VB 스크립트를 수정하는 경우 확실하지 않다 방법 :vbs를 수정하여 이벤트 로그를 보관하는 방법
- 만 수집 시스템, 응용 프로그램 및 보안 로그 모든 로그
- 을 이 아카이브 로그를 월, 일 및 년으로 만들고 매일 같은 폴더에 저장하고 덮어 쓰지 않습니다.
이벤트 로그를 보관하도록 VB 스크립트를 수정하는 방법은 무엇입니까? 나는 found one VB script 네트워크 공유 폴더로 이벤트 로그를 보관하는 것이 잘 작동,하지만 난에 VB 스크립트를 수정하는 경우 확실하지 않다 방법 :vbs를 수정하여 이벤트 로그를 보관하는 방법
당신은
예 ("Win32_NTEventLogFile SELECT * FROM")이 줄을 변경해야합니다 ("Win32_NTEventLogFile에서 선택 * 어디 LOGFILENAME = '응용 프로그램'")
또는
http://www.activexperts.com/activmonitor/windowsmanagement/scripts/logs/event/
를 참조 백업하고자도움이 될 것입니다.
요구 사항에 따라 다음 변경된 코드를보고 필요한 로그를 출력하고 매일 다른 폴더에 저장합니다.
VBS
Dim strComputer, objDir2
Dim current: current = Now
Dim strDateStamp: strDateStamp = dateStamp(current)
strComputer = "YourServer"
objDir2 = "Your File Server Path" & strDateStamp
Dim objDir1: objDir1 = "\\" & strComputer & "\c$\EVT"
clearEVTLogs = "No"
Set filesys=CreateObject("Scripting.FileSystemObject")
If Not filesys.FolderExists(objDir1) Then
createDir(objDir1)
If Not filesys.FolderExists(objDir2) Then
createDir(objDir2)
End If
strPath = objDir2 & "\"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate, (Backup, Security)}!\\" _
& strComputer & "\root\cimv2")
Set colLogFiles = objWMIService.ExecQuery _
("Select * from Win32_NTEventLogFile where LogFileName='Application' Or LogFileName='Security' Or LogFileName='System'")
For Each objLogfile In colLogFiles
strCopyFile = strDateStamp & "_" & strComputer & "_" _
& objLogFile.LogFileName & ".evt"
strBackupFile = "c:\EVT\" & strDateStamp & "_" _
& strComputer & "_" & objLogFile.LogFileName & ".evt"
strBackupLog = objLogFile.BackupEventLog _
(strBackupFile)
Call copyAFile(objDir1, strPath, strCopyFile)
If clearEVTLogs = "Yes" Then
objLogFile.ClearEventLog()
End If
Next
Function dateStamp(ByVal dt)
Dim y, m, d
y = Year(dt)
m = Month(dt)
If Len(m) = 1 Then m = "0" & m
d = Day(dt)
If Len(d) = 1 Then d = "0" & d
dateStamp = y & m & d
End Function
Function copyAFile(Byval strSourceFolder, Byval strTargetFolder, _
Byval strFileName)
Dim objFSO, booOverWrite, strResult
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(strSourceFolder & "\" & strFileName) _
And UCase(strSourceFolder) <> UCase(strTargetFolder) Then
If objFSO.FolderExists(strTargetFolder) Then
Else
strResult = "The destination folder does not exist!"
'copyAFile = strResult
Exit Function
End If
If objFSO.FileExists(strTargetFolder & "\" & strFileName) Then
strResult = "The file exists, overwritten"
booOverWrite = vbTrue
Else
strResult = "The file does not exist, created"
booOverWrite = vbFalse
End If
objFSO.CopyFile strSourceFolder & "\" _
& strFileName, strTargetFolder & "\", booOverWrite
Else
strResult = "The source file does not exist, or " _
& "identical Source and Target folders!"
End If
End Function
Function createDir(strDir)
Set filesys=CreateObject("Scripting.FileSystemObject")
Set objFSO = CreateObject("Scripting.FileSystemObject")
wscript.echo strDir
If Not filesys.FolderExists(strDir) Then
Set objFolder = objFSO.CreateFolder(strDir)
End If
End Function
여기 스크립트의 관련 부분을 게시하시기 바랍니다. 외부 소스에 대한 링크는 나중에 사용할 수 없으며 다른 사람들을 위해이 질문의 가치를 감소시킬 것입니다. – dc5