Free Power Tools Brochure
Get Mark Minasi's
17-page guide today!



      

advertisement

Get Newsletters

  • Get the Latest News
  • Product Updates
  • Helpful Tricks
  • Productivity Tips

Subscribe Now!

April 26, 2005 06:26 PM

JSI Tip 9293. FileNotify.exe freeware monitors file system events.

Rating: (0)
Windows IT Pro
InstantDoc ID #83512


Download FileNotify.zip.

The UserGuide.htm file contains:

Installation
Use an administrator account for installation.

Put FileNotify.exe where you want, for example in the WINNT directory.
Type in "FileNotify.exe -install" and this is it, installation complete.
To remove FileNotify type in "FileNotify.exe -remove".
This program does not require special DLL.

If you do an upgrade from a previous version, stop the service, close Event Viewer, replace FileNotify.exe with the new version and start the service.

We chose this minimalist installation scheme because we are sure you don't like to start heavy blind installation program on your production  park. You certainly have in mind "I hope it will not upgrade a DLL that is incompatible with existing programs !"

Platforms
FileNotify is a Windows NT 4.0/3.51/2000 service that works on Server and Workstation.
For NT 3.51 you must
have SP5.
Starting and stopping
Service long name is "File Notification". Start it in the service manager program.
Service short name is filenotify, use it with net start and stop command.
net start filenotify
net stop filenotify
Parameters
All directory parameters are in FileNotify.txt file, located in the same directory as the program.
Some advanced parameters are in the registry key HKEY_LOCAL_MACHINE\Software\XTWare\FileNotify
FileNotify.txt is parse during the service start. If you edit the file, you need to stop/start the service.

To edit FileNotify.txt you can use your usual text editor, or you can use FNAdmin.exe
When starting, FNAdmin ask for the file to open for editing. If this is the first time you start it, chose cancel.
Add, Edit or Delete entry.
When finished, press OK. If you just created the file give a name to save to.

We chose text file for parameters because we find this is more convenient than registry for remote computer admin. You can also easily spread the file on your park. The txt extension take advantage of default notepad association.


FileNotify.txt
Each line in this file use the following grammar:
<Source>,<Flags>,<Recursive>,<Parallel>,<Directory>,<Action>

<Source>
1 for File, 2 for Directory, 3 for both.

<Flags>
The flag tell witch event to look at.
1 = Creation
2 = Deletion
4 = Rename
8 = Modification
16 = Attributes change (read-only, archive, hidden, system)
32 = Security change
64 = Rename with long name support (see below <Action>)

<Recursive>
0 mean no recursive directory check.
1 mean recursive directory notification.

<Parallel>
This figure tell how many <Action> you can start simultaneously.
if <Parallel> if less or equal to 0 then it is replaced by 1.
For example if <Parallel> value is two, this mean you can have two <Action> running simultaneously, no more. If new file are added to <Directory> when two instances of <Action> are already running, FileNotify wait for one of the two <Action> to stop and then start a new one.

<Directory>
Put a fully qualified local directory
For example c:\temp, or c:\inetpub\ftproot\advanced users\sql
Don't use double quote for path with space in.

You can specify UNC path (remote directory and syntax like \\server\share\dir1\dir2) and it should work, but not guaranteed. With UNC path FileNotify service must be started under administrator account as local system account can't do networking. UNC path have not be tested on all version of Windows. If it doesn't work with the version you work with try to apply last service pack. Behavior not determined on no Windows server (Samba, disk array...). Tell me if you test such no Windows server.
You can't use local mapped drives as services can't see these objects.

<Action>
The full path to the program or batch. You can use %s to get full path to the new file.

One exception is for rename event, %s will contain the new name and the old name in that order, for example "c:\ftproot\newfile.txt c:\ftproot\oldfile.txt"
The rename2 event will use double quote separator for long name support
"c:\space directory\old file name.txt" "c:\space directory\new file name.txt"


Put comments by starting a line with a semicolon (;)

Look at the example section.


Registry

The registry path is HKEY_LOCAL_MACHINE\Software\XTWare\FileNotify

LogFile value specify the file to log to. If you need daily file add %s in name, this will be replaced by the date in yyyymmdd format. Default installation value is <FileNotify path\FileNotify.log>
For example:
c:\admin\filenotify\filenotify%s.log

Remove (or rename) this key to disable log.

EventLogFailure value specify if action failure should be trace to event log. Default value is yes (1).

LogFile format
<Date>,<Time>,<Status>,<Action>

Example:
04/26/1999,07:03:35,1,zip c:\temp\test.zip c:\temp\test\NewArchive.txt

<Date> always mm/dd/yyyy whatever regional settings are.
<Time> always hh:mm:ss in 24H format.
<Status> 0 = failure, 1 = success
<Action> the command line exactly as passed to NT

Remember that failure are also written to NT's EventLog (see EventLogFailure registry key)

General tips
  • If you need to access file on network neighborhood you must set FileNotify service to log on a Windows NT account that have this right. System account can't do network neighborhood.
  • Take care of recursivity. If the action writes in the directory is associated with you will have race condition.
  • If you have problems troubleshooting abnormal execution use the -debug option. With this option all text printed to stdout will appear as well as all interactive program window's. (FileNotify -help for more info)
  • The trigger for FileNotify to start an action is the last write-time change. Some programs change this value twice when writing a file, that's why FileNotify waits 1 second of "inactivity" on the new file before performing the action.
  • FileNotify can't monitor single file activity. You can do this easily using a batch file filter. For exemple you start "go.bat %1" and in go.bat you put a line like "if "%1"=="myfile.ext" goto action"
Example
FileNotify.txt

;Sample file for FileNotify
;
; Recursive file check starting at c:\inetpub\ftproot\database\customer list
1,1,1,1,c:\inetpub\ftproot\database\customer list,c:\inetpub\scripts\customerbcp.bat "%s"

; No recursive file check at c:\inetpub\ftproot\users
1,1,0,1,c:\inetpub\ftproot\users,0,1,c:\inetpub\scripts\zip.exe c:\temp\backup.zip %s -9

; No recursive check at c:\temp, 5 actions in parallel.
1,1,0,5,c:\temp,cmd /c copy %s \\webserver03\temp
; Directory change check (create+rename+delete)
2,1,1,1,c:\ftproot,cmd /c echo Creation %s >> c:\temp\directory.log
2,4,1,1,c:\ftproot,cmd /c echo Rename %s >> c:\temp\directory.log
2,2,1,1,c:\ftproot,cmd /c echo Delete %s >> c:\temp\directory.log

Version history
  • Version 1.3
    • Initial version.
  • Version 1.4 (11/20/99)
    • Registered version can now start if the user have no administrative rights.
  • Version 1.5 (04/27/00)
    • New FnAdmin user interface
    • Remove registration process
    • Clearer messages during installation
    • More error messages
  • Version 1.6 (07/01/00)
    • Maintenance release, no new feature.
  • Version 1.7 (11/11/00)
    • Maintenance release, no new feature.
  • Version 1.8 (07/28/01)
    • Adjust process to Backup privilege, according to Q188321
    • Delete event on files was not detected, corrected.
    • Rename event corrected
  • Version 1.9 (09/15/02)
    • Support added for Rename2 event for long file name



ARTICLE TOOLS

Add a Comment

There are no comments to display. Be the first one!
You must log on before posting a comment.

Are you a new visitor? Register Here

VB Script to enable user account

Do any of you guys have a VB script that could be used to enable a AD user account? We are setting up a "firecall" ID which will stay disabled until i...222-96219

advertisement

GOOGLE LINKS
SPONSORED LINKS
FEATURED LINKS

Podcasts

To successfully implement virtual desktops, IT administrators must carefully match user requirements to specific desktop technologies. Listen to this podcast to learn what you need to keep in mind when formulating your approach to desktop virtualization.

Downloads

PacketTrap IT is a comprehensive and affordable network management and application monitoring solution that solves problems associated with bandwidth, network and application performance, and connectivity. Gain insight into your network - try PacketTrapIT free for 21 days!

Web Seminars

Aside from its employees, data is an organization’s most important resource. Join Windows technical specialist and 11-time MVP John Savill to learn the best practices for managing data using features in Windows Server.
View this web seminar on demand!

eLearning Series

We bring the experts direct to you to share their real-world perspective and expertise. During each event, three sessions stream in real time, so you can learn, ask questions, and get solutions.
Upcoming event: Getting the Most with Exchange 2010 with Paul Robichaux

Subscribe to Windows IT Pro!

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.