0

I am attempting to create a script that will monitor a folder (a Dropbox folder).

When I need to shutdown my PC, I will just drop a file into the Dropbox folder. The script will see the new file, run a shutdown batch file, and delete the file in the Dropbox folder.

Please help me implement this.

To summarize:

  • Check folder for new files.
  • If there is one, run shutdown.bat.
  • Delete the file in the folder.
MultiplyByZer0
  • 4,341
  • 3
  • 27
  • 46
ayrnee
  • 29
  • 5
  • 2
    Can you post the batch file that you have tired creating? As many users will point out, SO isn't a code writing service –  Jun 16 '17 at 22:19
  • In terms of the file monitoring script I have nothing all I have is the shutdown file and an attempt I had before at trying to shutdown the computers over LAN but I kept getting a permissions error I was not able ti rectify. – ayrnee Jun 17 '17 at 23:09

1 Answers1

0

If I understand your problem correctly, you want to drop a file into a dropbox folder and that will trigger this batch file to remove that file, and call a shutdown batch file.

@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%
}

You should read up on running a batch file in the background to monitor the folder. May not be exactly what you want, but this is the best solution I could come up with.

These links should help you out more with your problem:

Folder Monitoring with Batch File

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