views:

332

answers:

3

ServerFault suggested I ask here. I need a directory watcher to trigger a command line FTP client to upload some files to a server. I don't care for the idea of keeping a connection to the server all day, so I need a directory watcher. This looks perfect, and I have tried everything I know possible. But I have hit the limit of my knowledge for something that is obviously very simple. If any one is interested, would point out my mistake?

I found this useful directory watcher service through google, but I have been unable to get it to work for me. I try to avoid asking for help with low skill things like this, but I have exhausted my knowledge and I don't know any C# so I can't troubleshoot the code. The log files say the service starts, and enters running mode, and stops, but nothing happens when I move a file into the watched folder.

If you find the code interesting or useful would you try it and let me know what works?

FWIW, this is the config file I was using: (but can't get it to appear)

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
   <configSections>
      <section name="watchInformation" type="DirectoryWatcher.WatchInformation, DirectoryWatcher"/>
   </configSections>
   <appSettings>     
         <add key="maxConcurrentProcesses" value="1"/>  
   </appSettings>
   <watchInformation>
      <directoriesToWatch>  
            <directoryToWatch path="C:\ftp_folder">
               <fileSetsToWatch>
                  <fileSetToWatch>
                     <eventsToWatch>
                        <eventToWatch type="All"/>
                     </eventsToWatch>
                     <programsToExecute>
                        <programToExecute path="cmd.exe" arguments="/C" />
                     </programsToExecute>
                  </fileSetToWatch>
               </fileSetsToWatch>     
            </directoryToWatch>
      </directoriesToWatch>
   </watchInformation>
</configuration>
A: 

@Thomas: I did ask in the articles comments, I believe yesterday, but it doesn't look like they are monitored anymore.

@CptSkippy: I didn't mean that it automatically stops running. It starts, enters running mode, then I test it. When nothing happens I stop the service, uninstall it, and try a different configuration.

@Nader: I'll try that, but I already attempted to give the full path to notepad, (and selected 'allow desktop interaction') but it didn't work then either.

@SerialHobbiest: The service logs in as Local System, so I don't think there should be a problem there, but I will try changing the security settings for notepad.exe and cmd.exe and try both of those. I haven't tried changing the security settings.

@Ramesh vel: I don't know C# at all, but I did download the Express dev environment for this, so I may give that a try this evening after business. What would the best documentation be to learn to debug acceptably. I only just got done with a beginners python tutorial, so I only just know OOP. I have no useful experience.

Thanks guys for your suggestions.

Radix
A: 

Your program might not be able to find cmd.exe.

Try to fully specify the path... usually its C:\Windows\System32\cmd.exe

Nader Shirazie
A: 

What ID is the program running under? What groups is it a member of? It might not have permissions to run cmd.exe - in the past, I've had to add security groups to cmd.exe on a server to allow a low-privilege account to run it.

serialhobbyist