Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

up vote 5 down vote accepted

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

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.