获取Windows事件日志列表VBA访问

时间:2022-05-15 11:47:18

获取Windows事件日志列表VBA访问

I am attempting to generate XML Tasks set up to trigger on events. Therefore I need the exact format of each log to inject into a generic XML template. Is there any way I can plug into the highlighted fields above to add them to a table in my database?

我正在尝试生成设置为触发事件的XML任务。因此,我需要将每个日志的确切格式注入到通用XML模板中。有什么方法可以插入上面突出显示的字段,将它们添加到我的数据库中的表中?

1 个解决方案

#1


0  

After much research the closest answer I could find was to scan the registry folders for all the available logs.

经过大量研究后,我能找到的最接近的答案是扫描注册表文件夹中的所有可用日志。

For the fields I was after these were in the location:

对于我在这些之后所在的领域:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\

From here on I used a loop in order to get the folder names. although to get all the results I will have to scan their subfolders (this is done by changing the path. Here is a code snippet below in case this problem is found by anyone else.

从这里开始,我使用循环来获取文件夹名称。虽然为了获得所有结果,我将不得不扫描它们的子文件夹(这是通过更改路径来完成的。下面是一个代码片段,以防其他人发现此问题。

Function test()
Const HKEY_LOCAL_MACHINE = &H80000002
Dim temp As Object
Dim strComputer As String
Dim rPath As String
Dim arrSubKeys()
Dim strAsk

strComputer = "."
Set temp = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\default:StdRegProv")

rPath = "SYSTEM\CurrentControlSet\Services\EventLog\Application"
temp.EnumKey HKEY_LOCAL_MACHINE, rPath, arrSubKeys
For Each strAsk In arrSubKeys
    Debug.Print strAsk
Next
End Function

#1


0  

After much research the closest answer I could find was to scan the registry folders for all the available logs.

经过大量研究后,我能找到的最接近的答案是扫描注册表文件夹中的所有可用日志。

For the fields I was after these were in the location:

对于我在这些之后所在的领域:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\

From here on I used a loop in order to get the folder names. although to get all the results I will have to scan their subfolders (this is done by changing the path. Here is a code snippet below in case this problem is found by anyone else.

从这里开始,我使用循环来获取文件夹名称。虽然为了获得所有结果,我将不得不扫描它们的子文件夹(这是通过更改路径来完成的。下面是一个代码片段,以防其他人发现此问题。

Function test()
Const HKEY_LOCAL_MACHINE = &H80000002
Dim temp As Object
Dim strComputer As String
Dim rPath As String
Dim arrSubKeys()
Dim strAsk

strComputer = "."
Set temp = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\default:StdRegProv")

rPath = "SYSTEM\CurrentControlSet\Services\EventLog\Application"
temp.EnumKey HKEY_LOCAL_MACHINE, rPath, arrSubKeys
For Each strAsk In arrSubKeys
    Debug.Print strAsk
Next
End Function