Click here to Skip to main content
15,887,267 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I use freeASPupload to upload file that containing webpages to a "Public" directory in win2003 server with the idea of somehow evaluate all the risks before put it onto the webpage. The Public is setup as just read/write but not to execute.

The server has virus scan and thereofre I guess it would be checked automatically on virus.

But I would like to have a script run as deamon in the window server so that the file that enter into this directory will be checked by the programs in the script. It would be a bit like Linux cron run on schedule! Any easy solution for window?

Of course the ideal way would be a file creation triggered action but I have no idea how this could be done??

rgds,
kfl.
Posted

To setup a task to run on a schedule would be Windows Task Scheduler[^].

Most virus scanners have command line options to scan single files so if you know this you could use the Process.Start Method[^] to launch such a scan from you code once the file has been uploaded, this can also be used to launch other programs as well.
 
Share this answer
 
Thanks. I tested it by create a little file called wcron.bat containing just one line to list dir to a file and it works ok, except that the window task scheduler seem only can be set to perform on "day" as the basic unit rather than Linux Cron where you can ask to check it once every minute or even shorter. Any way to overcome this shortcoming?

Since task scheduler asked me to give the administrator password which would mean this file wcron.bat could potential be very dangerous; therefore I set the file to refuse write by Internet user. Is this sufficient?

The startmethod you mentioned look pretty complicated to me. Any where I can find an example for file-create triggered action?

Just a question always on my mind is how Linux manage to do very frequent check (run a script that containing programs) without incur excessive overhead for the system?

rgds,
kfl.
 
Share this answer
 
Comments
Rod Kemp 7-Nov-10 6:59am    
Sorry I didn't realise you had responded, if you want to respond to an answer add a comment to the answer don't post an answer as a response.
Anyway the windows task scheduler can trigger a task down to 5minute intervals, that setting is in the advanced settings section.
For the start method look at the one that takes 2 strings in the constructor, the first string is the path and name of the program to run and the second string has the arguments to pass to the program. To have a file create triggered action you would use a FileSystemWatcher. Have a look at this article - http://www.codeproject.com/KB/files/FileSystemWatcherChaos1.aspx
KFLee 7-Nov-10 7:25am    
The down to minite solution will do the trick, thank you. The trigger article looks very comprehensive and also complicate and will need time to study.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900