Search code examples
windowsshellfilesystemwatcher

How to start a FileSystemWatcher when the window shell starts


I want to create a shell extension and I need it to respond to events like file created. I know how to use the FileSystemWatcher class but I don't know how to make sure it gets initialized when the shell does. Is there a good way to do this or am I better of creating an application that starts on startup and have it communicate with the shell extension?


Solution

  • Create a task that starts every 5 minutes and looks if a previous instance is already running. The task will start at reboot and a program crash or even a scheduled exit at midnight.
    See solution with PowerShell for some other ideas.