2017-06-16 63 views
0

我正在尝试创建一个脚本来监视一个文件夹(一个Dropbox文件夹)。文件夹监视/批处理文件执行

当我需要关闭我的电脑时,我会将一个文件放入Dropbox文件夹。该脚本将看到新文件,运行关闭批处理文件,并删除Dropbox文件夹中的文件。

请帮我实施这个。

总结:

  • 新文件支票夹。
  • 如果有,请运行shutdown.bat
  • 删除文件夹中的文件。
+2

你能后,你已经厌倦了创建批处理文件?许多用户会指出,SO不是代码编写服务 – 2017-06-16 22:19:02

+0

就文件监控脚本而言,我所拥有的并不是我所拥有的关机文件,而是一种尝试通过LAN关闭计算机的尝试,但我保留获得权限错误我无法纠正。 – ayrnee

回答

0

如果我正确理解您的问题,您希望将文件拖放到保管箱文件夹中,并且会触发此批处理文件以删除该文件并调用关闭批处理文件。

@echo off 
cls 

rem set these first before running the script 
set pathtoDBfile= 
set sdBatfile= 

rem check if the file in the dropbox folder exists 
if exist %pathtoDBfile% (
    del /q %pathtoDBfile% 
    call:%sdBatfile% 
} 

您应该了解在后台运行批处理文件来监视文件夹。可能并不是你想要的,但这是我能想出的最佳解决方案。

这些链接可以帮助你了解更多您的问题:

Folder Monitoring with Batch File

Windows XP or later Windows: How can I run a batch file in the background with no window displayed?