2

I have an ultralight PC with Windows 7 that I use during my daily bus commute. Since the processor speed is limited, I'm looking for a way to disable/enable Dropbox when I'm not connected to a WiFi network. (Dropbox seems to use a steady chunk of my CPU even when it can't sync anything.)

There is an option to disable syncing via the Dropbox tray icon, but I'd like this to be as seamless as possible. I'm a .NET developer, so writing code is an option. So far what I've considered:

  • A Windows task that is triggered when I enable/disable the WiFi card via the hardware switch. This could run a batch file to start/stop the Dropbox process. I'm having trouble finding an event to trigger off of, though.
  • An Autohotkey macro to start/stop the process. Too manual.
  • A C# app that would detect a network connection and start/stop Dropbox. Seems like it would be a pain to write.

Are there any options I'm overlooking? If someone could point me to a resource that would help me implement something similar, I would appreciate it.

2 Answers 2

1

You could take a look at this article. It's about tracking changed network connections and uses Win32-api.

There are also .Net-events for network-changes. But as described in this StackOverflow-Question, they're not fast or not reliable.

Apart from that, an available network-connection is not always equal to an available internet-connection. You have to test if an internet-connection is established.

I don't know how to check internet-connection, but afaik microsoft is pinging his own website to determine if there's an available connection and update the network-connection-icon in the systray. For your purpose, following code-snipet could do the work:

try
{
   System.Net.IPHostEntry = System.Net.Dns.GetHostByName("www.google.com");
   return true;
}
catch
{
   return false; // host not reachable.
}
0

Would you be willing to use a shortcut to disable wireless instead of using the laptop switch?

If so, try using powershell and devcon to query/enable/disable the wireless adapter, along with the appropriate dropbox start/stop action when enabling/disabling:

Shutdown:

taskkill /f /im Dropbox.exe /t

Startup:

cd C:\Users\[WindowsUsername]\AppData\Roaming\Dropbox\bin
start Dropbox.exe

Devcon and PowerShell examples:

Enable/disable wireless interface in a bat file

Shortcut for enabling/disabling wireless

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .