Home > Windows Server Tips > Network Management > How to receive automatic notification of file changes
Windows Server Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

NETWORK MANAGEMENT

How to receive automatic notification of file changes


Serdar Yegulalp, Contributor
11.06.2007
Rating: --- (out of 5)


Expert advice on Windows-based systems and hardware
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


The prolific (and very funny) Microsoft Scripting Guy site offers a simple piece of VBScript that monitors a given file for changes, and then automatically fires off a notification in a text window if something has (or hasn't) changed.

The script in question monitors a file that is ostensibly an application's log file, which is one of the many possible applications for this script. It also runs in a continuous loop, so it doesn't need to be run more than once to work its magic.

For the best results, run this script from the console and not from the GUI. Otherwise, it's difficult to terminate easily without breaking out Task Manager.

There are several ways to modify this script, such as polling a remote computer rather than a local one for any changes. Obviously this only works if the remote computer can be accessed over the network via NetBIOS (check those firewalls and policies).

The Scripting Guy site has how-to instructions that are not difficult to implement. The hardest part is making sure the remote computer processes the commands correctly.

Another script modification is to change the sleep state for the script -- i.e., to make it wait for a different period of time. To do this, you take the number of seconds you want to wait, multiply it by 1,000, and then change the Wscript.Sleep statement in the script to use the calculated number.

To wait an entire hour, use the value 1800000; to wait a mere minute, use 60000. On most modern hardware you could even poll every 10 seconds (10000) without incurring a significant amount of overhead.

Finally, you can also modify the script so that it only does something when changes are detected. To do that, just place the commands in question to run in the first part of the if block at the end of the script:

If strLatestTimestamp <> strOriginalTimestamp Then
strOriginalTimestamp = strLatestTimeStamp
[other commands go here]
Else
[rest of script]

One possible addition is sending an email using the blat command-line mailer:

Set g_shell = CreateObject("WScript.Shell")
g_shell.Run(blatCommand, 0, True)

In the code above, blatCommand is the command-line string that executes blat and sends whatever message is needed.

About the author: Serdar Yegulalp is editor of Windows Insight (formerly the Windows Power Users Newsletter), a blog site devoted to hints, tips, tricks and news for users and administrators of Windows NT, Windows 2000, Windows XP, Windows Server 2003 and Vista. He has more than 12 years of experience working with Windows and contributes regularly to SearchWinComputing.com and other TechTarget sites.

Rate this Tip
To rate tips, you must be a member of SearchWindowsServer.com.
Register now to start rating these tips. Log in if you are already a member.




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


RELATED CONTENT
Windows System and Network Performance Monitoring
Quick hits: Troubleshooting service account failure, batch job execution
Troubleshooting common Windows service failures
Monitor network bandwidth with CyberGauge
Optimizing NTFS file system performance
For Active Directory performance gains, delegate the _MSDCS DNS zone
Sysinternals TCPView monitors network connections on Windows systems
Create data collector sets through Vista's Performance Monitor
Data collector sets simplify monitoring of Vista performance
Performance monitoring in Windows: An overview
RRAS utility in Windows Server 2003 traces network problems

Windows File Management
Windows NTFS Tutorial
Windows registry hack improves offline file access for mobile users
How to format NTFS: More tricks to improve file system performance
Windows scripting secrets for disk quota management
Optimizing NTFS file system performance
Identify file extension types with TrID
Windows System File Checker helps stop system failures
How to reverse NTFS object ownership from administrators to object's creator -- and why
Use PageDefrag to defragment immovable system files
Case Study: Troubleshooting Distributed File System Replication
Windows File Management Research

Network Management
Implementing simple Network Access Protection for Windows Server 2008
Immediate steps for Windows disaster recovery
Windows registry hack improves offline file access for mobile users
Reducing the size of network backups in Windows
Monitor network bandwidth with CyberGauge
Adding a standalone printer to Active Directory with Windows Vista
Sysinternals TCPView monitors network connections on Windows systems
How to install low-voltage wiring such as Ethernet or coax cable
Wireshark, reincarnation of Ethereal, sniffs wide variety of networks
RRAS utility in Windows Server 2003 traces network problems

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
NTFS  (SearchWindowsServer.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



Server Room Design - Planning, Cooling, Maintenance
HomeTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersIT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2004 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts