Run a script when connected to wireless

3

3

I'm after a way of running a script (on Windows) when a network connection is established.

Background: I'm looking at the potential of having a low powered computer that sits in the boot of my car storing a lot of audio files, running Subsonic and using the Android app as a "jukebox" controller that plays the music through the soundcard of the computer to an input on the stereo, or broadcasts it over a local radio channel to my car stereo. When I arrive home, it will connect to my home wireless, run a sync with my media server to download any music it hasn't got on it, then hibernate.

My question then, is how can I run the sync when I connect to the network? My current idea is to ping the gateway every 30 minutes or so, and if the gateway is pingable, run the sync and hibernate, or if not ping 30 minutes later.

I would prefer some Windows-based trickery such as batch-based files or PowerShell, but if the OS will run Subsonic then I may consider that as well.

I could have a lot of CD's in my car...but that's effort to remeber to do - I'm ovbiously not a fan of the easy life.

tombull89

Posted 2012-02-10T15:58:44.817

Reputation: 6 533

Answers

5

Use the windows task scheduler. From the task scheduler (Win7 Control Panel, administrative tools), create a new task to specify your sync batch file. On the conditions tab, there is a network option. Check the

"Start only if the following network connetion is available"

and also any other conditions in triggers etc, to limit the sync to happen per your needs. enter image description here

jdh

Posted 2012-02-10T15:58:44.817

Reputation: 6 645

0

There is a more direct way: use the NetworkConnected event (ID 10000) as trigger: Task trigger configuration

This way the task runs immediately every time the network is connected.

You may also want to uncheck "Start the task only if the computer is on AC power" on the Conditions tab and select "Run whether user is logged on or not" on the General tab.

Thanks to jdh for the idea of using Task Scheduler.

EM0

Posted 2012-02-10T15:58:44.817

Reputation: 1 703