简体   繁体   中英

Copy new files added to a folder to another folder in Windows

I'm looking for a way to put an event trigger on a Windows XP folder which would automatically copy a file from folder1 to folder2 when the file as created in folder1, ideally with System permissions. The purpose is to make a secure repository for files which would be protected. I've looked at WMI, but can't figure out how to get it to trigger on the folder. Any pointers in the right direction would help. Thanks!

If you want to use WMI and need to monitor your folder all the time, you can use WMI permanent event subscription .

You would:

  • Create a WMI filter ( a query like this, for example: "Select * From __InstanceCreationEvent Within 5 Where TargetInstance Isa 'Cim_DataFile' And TargetInstance.Drive = 'C:' and TargetInstance.Path = '\\folder\\subfolder\\'")

  • Create a WMI event consumer (a batch or VBScript file to copy the created file to your new location)

  • Bind the two together

This way you would ensure that the folder is monitored 'at all times' (as long as WMI service is running). You can use VBScript, PowerShell, C# or MOF to set this up. (See the Script Center blog for details)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM