简体   繁体   English

将添加到文件夹的新文件复制到Windows中的另一个文件夹

[英]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. 我正在寻找一种在Windows XP文件夹上放置事件触发器的方法,当在folder1中创建文件时(最好具有系统权限),它将自动将文件从folder1复制到folder2。 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. 我看过WMI,但无法弄清楚如何在文件夹上触发它。 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 . 如果要使用WMI并且需要一直监视文件夹,则可以使用WMI 永久事件订阅

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\\'") 创建一个WMI筛选器(类似这样的查询,例如:“从__InstanceCreationEvent中选择* 5,其中TargetInstance Isa'Cim_DataFile'和TargetInstance.Drive ='C:'并且TargetInstance.Path ='\\ folder \\ subfolder \\'”)

  • Create a WMI event consumer (a batch or VBScript file to copy the created file to your new location) 创建一个WMI事件使用者(一个批处理文件或VBScript文件,将创建的文件复制到您的新位置)

  • Bind the two together 将两者绑定在一起

This way you would ensure that the folder is monitored 'at all times' (as long as WMI service is running). 这样,您可以确保“始终”监视文件夹(只要WMI服务正在运行)。 You can use VBScript, PowerShell, C# or MOF to set this up. 您可以使用VBScript,PowerShell,C#或MOF进行设置。 (See the Script Center blog for details) (有关详细信息,请参见脚本中心博客

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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