JFLarvoire / SysToolsLib

A library of Windows and Linux system management tools
Apache License 2.0
314 stars 93 forks source link

IO.FileSystemWatcher not working #17

Closed fisher1551 closed 6 years ago

fisher1551 commented 6 years ago

I'm trying to use IO.FileSystemWatcher to watch a folder and move files placed in the folder. I tried to strip this down as simple as possible in the attached. The powershell works fine by itself, but trying to run it as a service fails. It will create the service, but when I copy files to c:\backup, nothing happens. Running the code by itself in Powershell, it works fine. BackupManager.txt

JFLarvoire commented 6 years ago

From the context I infer that you're building a new service based on PSService.ps1. One possible clue: This looks like a problem with account permissions. Try running the service as user yourself, instead as the default LocalService user. See the -UserName option help for details. Closing this, as this is not a problem in PSService.ps1; This is a problem in your own code.