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

WINDOWS SYSTEMS AND NETWORK ADMINISTRATION

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 File Management
Using DFSR for SYSVOL replication in Windows Server 2008
Key DFS improvements in Windows Server 2008 R2
Quick tips for troubleshooting NTFS permissions
Using NTFS on a non-Windows OS with NTFS-3G
File classification the automated way with Windows Server 2008 R2
Using DFS to create file system virtualization in Windows Server 2008
File server migration tips for Windows Server 2008
Windows Distributed File System (DFS) Tutorial
Planning a file server migration to Windows 2008
Windows Distributed File System (DFS) Namespace primer
Windows File Management Research

Windows Systems and Network Administration
Troubleshooting Windows application crashes or hangs
Converting VMware ESX machines to Hyper-V format
Using DFSR for SYSVOL replication in Windows Server 2008
Top 25 Windows PowerShell commands for administrators
Key DFS improvements in Windows Server 2008 R2
Free Windows security tools every admin must have
Group Policy makes strides in Windows Server 2008 R2
Quick tips for troubleshooting NTFS permissions
Common causes of Windows server security vulnerabilities
Cutting the cost of Windows identity and access management

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
HomeTopicsBlogsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersIT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online 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