RE: Start scheduled batch file as soon as source file changes
- From: Prashant <Prashant@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 25 Dec 2006 22:23:00 -0800
Is There any process by which the file in destination drive will get updated
as soon as the file in the source drive is changed....
Prashant
"urkec" wrote:
You could use WMI InstanceModificationEvent. You can find about it in Windows.
200 scripting guide.
I asked a similar question here, but it seems it is better to use Schedulde
tasks and copy needed files periodically.
Anyway, here is the script. The loop is infinite, so you would have to stop
the Wscript.exe and wmiprvse.exe processes manually.
Set fso = CreateObject ("Scripting.FileSystemObject")
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
("SELECT * FROM __InstanceModificationEvent WITHIN 10 WHERE " _
& "TargetInstance ISA 'CIM_DataFile' AND " _
& "TargetInstance.Name='c:\\scripts\\test.xls'")
Do
Set objLatestEvent = colMonitoredEvents.NextEvent
fso.CopyFile "C:\scripts\test.xls", "D:\Archive\", true
Loop
--
urkec
"Prashant" wrote:
Hi all,
i have a mapped drive on Windows 2000 OS. I m copying the file from mapped
drive using a batch file which is scheduled.
Now what i want, the batch file should run as soon as the source file in
mapped drive is changed or updated (its a Excel file).
Solution & suggestion are appreciated.
- Prev by Date: RE: User info to Excel ***
- Next by Date: Re: Script to create folder named by date
- Previous by thread: Robocopy error since migration 2000 -> 2003
- Next by thread: Re: Script to create folder named by date
- Index(es):