|
WMI Fun !! 〜 WMIに興味がある方・システム管理者必見!! 〜 WMI StepWMI SampleWMI ReferenceWMI LibraryPersonalLinkAbout WMI Fun !! |
|
|
|
WMI Fun !! > WMI Sample (VB) > イベントログの内容を保存する |
|
|
Panasonic Let'snoteを長年愛用しています、その理由はMy Let'snoteで…
インクを買うよりもしかしたら安い?インクジェット複合機HP Photosmart 5510 白いご飯や日本酒にもとても合うにしんのきりこみがマイブームです イベントログの内容を保存する: Win32_NTEventLogFile - WMI Sample (VB)Topics
イベントログの内容を保存するサンプルプログラムです。Win32_NTLogEventFileクラスを使用します。
Sample Code
Private Sub Command1_Click()
Dim EveSet As SWbemObjectSet Dim Eve As SWbemObject Dim Locator As SWbemLocator Dim Service As SWbemServices Dim Security As SWbemSecurity Dim Ret As Long Const wbemPrivilegeBackup = 16 Set Locator = New WbemScripting.SWbemLocator Set Security = Locator.Security_ Security.Privileges.Add wbemPrivilegeBackup Set Service = Locator.ConnectServer Set EveSet = Service.ExecQuery _ ("Select * from Win32_NTEventLogFile where LogFileName='Application'") For Each Eve In EveSet Ret = Eve.BackupEventLog("c:\applicationlog.evt") Next If Ret = 0 Then MsgBox "アプリケーションログの保存に成功しました。" Else MsgBox "アプリケーションログの保存に失敗しました。" End If Set EveSet = Nothing Set Eve = Nothing Set Locator = Nothing Set Service = Nothing Set Security = Nothing End Sub
Comment
実行するとイベントログの中のアプリケーションログをcドライブにapplicationlog.evtという名前で保存します。もちろんアプリケーションログ以外にもソース上のWQLにてクエリー条件を変更すれば保存可能です。LogFileNameプロパティをシステムログであれば「System」、セキュリティログであれば「Security」を指定します。
Recommended book
個人的にお勧めする本の紹介です。
|
|
ご意見・ご要望・ご感想をこちらのアンケートからお待ちしています |
| ∧ ページの先頭へ… |