1

Is there an event or other means by which a VB.NET program can be notified when a Windows 7 defrag has completed (so the program can instruct the PC to shut down)?

U1199880
  • 907
  • 1
  • 10
  • 21

1 Answers1

2

You should be able to use EventLog.EntryWritten event to monitor for events. On Windows 7, an event in Application log with Source = "Defrag" may indicate completion of defragmentation. You can then examine the id - should be 258, and description will say something like The disk defragmenter successfully completed defragmentation on (C:).

Here is a screenshot from my home PC to prove the above:

enter image description here

Victor Zakharov
  • 25,801
  • 18
  • 85
  • 151