Bat file to backup when the cable is connected

1

I need to do a Bat file (or something like that) that do a Incremental Backup of some especified folders when, and just when, the Ethernet Cable is connected.

How can I do it? I have no idea how can I start..

ZeroNegative

Posted 2014-01-20T11:21:57.143

Reputation: 23

Question was closed 2014-01-21T01:49:48.070

Answers

0

You need to create a Windows scheduler task that fires based on an event in the Event Log.

This previous answer will help: How to launch a command on network connection/disconnection?

You will probably need to add a delay as it takes quite a time for Windows to fully start the network and assign drives, etc.

Note that this assumes you are using Vista or above.

Do actually do the backup, try looking up the help for the Robocopy or xcopy commands.

Julian Knight

Posted 2014-01-20T11:21:57.143

Reputation: 13 389

0

This PowerShell code will show you all installed adapters, and their connection status.

Get-WmiObject -Class Win32_NetworkAdapter | Format-Table -Property Name, NetConnectionStatus -AutoSize

Status of 2 means connected. There are more details and in-depth examples on the Hey, Scripting Guy! site.

This article gives you more options, if PowerShell is not your thing - you could do something similar with netsh.

rossnz

Posted 2014-01-20T11:21:57.143

Reputation: 111