0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

イベントログのファイルを削除する方法

Last updated at Posted at 2021-04-09

概要

ちょっと今Bluetoothを監視するアプリを作っていますが、そのためにイベントログを作成しました。
ただ、作成はできたものの、プログラム上からイベントログが消せないという問題に・・・。
今回はプログラムとかインフラとか全然違う話題です。メモですね。

イベントログが消せない理由(想像)

想像ですが、イベントログはWindowsサービスのWindows Event Logがコントロールしているようです。
そのため、Event Viewrのプロパティでログのパスを得て、そこから管理者権限やセーフモードで消しても、削除時に拒否されるか、削除できても次の再起動時に復活します。(復活するのが不思議ですが、、、本当に復活します、、、)

削除手順

  1. EventViewrで削除したいイベントソースのログパスを控えておいてください
  2. WindowsサービスのWindows Event Log無効にしてください
  3. PCを再起動してください
  4. PowerShellGet-EventLog -LogName "LogName" | Select-Object Source -Uniqueを実行してください
  5. PowerShellRemove-EventLog -LogName "LogName"を実行してください
  6. ログパスをもとにファイル*.evtxを削除してください
  7. レジストリ\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLogも削除
  8. PCを再起動してください

うぇい

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?