Advice on how to trigger a Windows task on a specific event

1

Operating System: Windows 10

I currently have a task that triggers anytime event ID 10000 occurs in

Applications and Service Logs -> Microsoft -> Windows -> NetworkProfile -> Operational

A cmd file is called with an argument passed to it (a host name), which calls a batch file. This batch file loops to check if a ping can be completed to a specific host on my network. If the ping returns an error, the VPN (device tunnel) is called (rasphone -D connection-name) and then the ping is attempted again. If at any point the ping is successful, the batch file ends.

So, if a user is already on our LAN when their computer connects to the network, whether the connection is wired or wireless, the VPN never starts because the target host ping replies successfully. Alternatively, if a user is external to our LAN, the target host is not reachable, and the VPN connects.

This works fairly well, but the task could be more robust if I could query the current connection name. If a computer is connect to our LAN via a wired or wireless connection, both the "name" and description "desc" reference my domain suffix (Connection-specific DNS suffix). Once the VPN is established, that specific connection will also reflect the same DNS suffix.

The Question: How to query the Ethernet adapter and wireless adapter for specific DNS info. If info is true, then I won't call the VPN. If the information is false, then I will call.

David_A

Posted 2020-01-09T21:59:16.397

Reputation: 11

Have you looked into using Powershell Get-NetIPConfiguration, Get-NetAdapter | fl for example.. – HelpingHand – 2020-01-09T22:11:03.070

1ipconfig /all | findstr "DNS Suffix" should get you started ... – DavidPostill – 2020-01-10T21:05:03.160

No answers