I have a batch file that runs whenever I log in on my laptop. I only want the batch file to execute when I'm on my employer's network. At home, I'd like the batch file to simply exit.
What's an easy way to detect (from a batch file) whether I'm on a certain network?
A generic approach to check for specific network characterisics, e.g. a specific IP-Address, aber given server IP or the output of a traceroute. For this to work, it is important to know the differences in the network topologies and exploit them. A more detailed explaination would required some more information on the problem setting.
I could ping our domain controller and check for an error:
The downside is that I have to wait for a timeout when it doesn't work. I was hoping for something immediate. I'm open to better suggestions.
I could check whether the default gateway is set for work:
At a command prompt enter echo %logonserver% and see if your domain computer is returned as the server that you are connected to.
In fact, here is an even better way, put this in your bat file....
Hope that helps. if you know the authentication server name you can obviously add a conditional equal statement in the if portion to confirm that the server exists, then run the remainder of your batch file. And of course the ELSE portion would simply exit.