If you use SHIVA VPN Clients then your going to love this bit of code... this registry setting actually changes when the tunnel is active... if you find this useful please let me know!!

$VPN = READVALUE ("HKEY_LOCAL_MACHINE\Software\Shiva Corp.\Shiva VPN Client","DomainTunnelUp")

IF $VPN = 0
?"VPN connection!"
endif