Hi,

When being abroad, your windows laptop might consume consideral amounts of data, making you poor.

Especially when travelling around using a 3G or 4G hotspot , you might burn your data quickly since windows can’t tell where you are. It just spots a wireless lan and starts updating. Especially with windows 10 coming up, that might eat your data pretty quickly. Worst case, you’re getting poor….

The script below checks if your at home or at work. It then turns on windows update services.
If somewhere else, the windows update services are stopped and also disabled.

Run as administrator and/or schedule at logon or windows startup.
Change the ip addresses to your own network gateway
If no valid address found, windows update services are disabled!!
Add your own services to the appropriate lines.
Build in as many checks that you like by repeating the line starting with “for /f “delims=:”
Do check from a command line if the reply is mentioned.
Script is tested with english and dutch versions of windows 7 and windows 10 and works.

Have fun!

Regards,
Harold Snippert

#######################################

create file:
pingscript-turnonoff-windowsupdate.cmd

#######################################

rem script created by Harold Snippert november 1st 2015
rem
rem turns off data eating services like windows update, when not at home and when abroad
rem saves money
rem
rem schedule on windows machine at logon or run with admin privileges
rem first ping to gateway, if reply from gateway all is fine, turn on services
rem no ping? turn off data eating services like windows update
rem mind you, windows update services are turned off by default by this script
rem no warranties…..
rem
rem 173.194.65.101 is IP for google.com, replace local ip addresses by google ip to test
rem

@echo off

echo send ping to ip that is listed in the line

rem this line is for english computers
for /f “delims=:” %%I in (‘ping -n 1 192.168.1.254’) do if “%%I”==”Reply from 192.168.1.254” (goto pingisgood)

rem this line is for dutch computers
for /f “delims=:” %%I in (‘ping -n 1 192.168.1.254’) do if “%%I”==”Antwoord van 192.168.1.254” (goto pingisgood)

rem add extra lines for multiple subnets
rem for /f “delims=:” %%I in (‘ping -n 1 173.194.65.101’) do if “%%I”==”Reply from 173.194.65.101” (goto pingisgood)

:pingisnotgood
echo no reply from local network, we’re not at home, turn off services that eat your data.
sc config “wuauserv” start= disabled
net stop wuauserv

rem add your own services here

goto endpingscript

:pingisgood
echo yes, a reply from local network, we’re at home, turn on services
sc config “wuauserv” start= delayed-auto
net start wuauserv

rem add your own services here

goto endpingscript

:endpingscript

rem to debug output, remove remark below
rem pause