Dropbox – Automatically Standby PC After Sync

Dropbox – another piece of software I couldn’t possibly live without.

If you use Dropbox, you may have come across a situation whereby you’ve just put a few large files in your Dropbox which will take some time to sync.

One solution to this problem (without leaving your machine on all day or night) is to use a batch file which does the following:

  1. Uses a small executable created by a member of the Dropbox forums
  2. This executable checks the status of Dropbox (synching, in-use, up-to-date etc)
  3. The batch script simply runs in the background and checks the status of Dropbox every 30 seconds
  4. If the status is up-to-date, the script executes a command which puts the machine in to standby.

Code

@echo on
:CHECKSTATUS
dbFileStatus.exe "C:\location\to\DropboxFolder" > dbstatus.txt
findstr /m "up to date" dbstatus.txt
if %errorlevel%==0 (
%windir%\System32\rundll32.exe powrprof.dll,SetSuspendState
) else (
SLEEP 30
GOTO CHECKSTATUS
)

  • Replace C:\location\to\DropboxFolder with the location of your actual Dropbox folder
  • The SLEEP is in there to prevent the script from looping it self hundreds of times per second. It is set to 30 seconds but this is configurable.
  • %windir%\System32\rundll32.exe powrprof.dll,SetSuspendState - this makes the machine go to standbychange it to %windir%\System32\shutdown -s -t 0 if you want to shutdown instead.

 

Download

You can download the batch script from here – it also includes the sleep command line tool as I know some Windows systems do not have it by default (Windows XP being one of them).

This entry was posted in Tech and tagged . Bookmark the permalink.

One Response to Dropbox – Automatically Standby PC After Sync

  1. Carl says:

    Fantastic!

Comments are closed.