Link to home
Start Free TrialLog in
Avatar of Simon336697
Simon336697Flag for Australia

asked on

Executing a batch file only if the laptop is located on a particular subnet.

Hi guys,

Hope you can help.

Requirement/s:

- Back up a folder on a laptop daily to a network location.
- Only run the backup task IF the user is located on subnet 10.60.10.x
- System in question is a laptop that gets a DHCP address.

I can generate the backup script, but what Id like help si the following:

1. How to code the script so that it only runs IF the laptop is given a DHCP address of 10.60.10.x and not another DHCP address, meaning it is on a different subnet

2. If the user is not connected to the LAN, and the task runs, to not run the script at all. That is, Id like the script to be able to check for a network connection, and if none, to abort the running of the backup.

Any help would be greatly appreciated.

Thank you..

Simon

Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

The easiest way is to look for a known network folder or file and abort if it does not exist

i.e.

if exist \\computername\share backupfiles

SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Simon336697

ASKER

Thank you so much guys....Sorry about the delay in allocating points for this.

Much appreciated.

Simon