Route print batch file




















My initial code extracted the IP address rather than the subnet address. The code below will fix this oversight. Note also that extracting the output from a console command is not really nice programming because it is not robust. Sometimes it cannot be avoided. Counting spaces or full stops in the line IPv4 Address. This is why I used the colon : as a delimiter to extract the IP address.

What remains is to extract the first three octets, which the inner loop in the code below will do. A really robust method would be based on WMI. The code at the very bottom is an example you could try. IPAddress i wscript. IPAddress wscript. You need to create a loop in order to process all IPv4 addresses. There are also several other issues that will cause your batch file to fail or to be fragile.

I recommend you study the modified code below in detail to see what I mean. Moreover, run those command as admin. Once you sure those route exist and those command works separately then just wrap them all in a bat file like.

Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Asked 7 years, 8 months ago. Active 7 years, 8 months ago. Viewed 22k times.

I just needed to delete and add route on the routing table of windows, as follows: route delete 0. Improve this question. And what happens when you do this? FYI: technet. That's it. Rahul not sure what im doing wrong, but i did test that but it didn't worked. Active Oldest Votes. Improve this answer. Thank you, that works fine. If I check IP for a blank string, i know when it is disabled or not present at all.

Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Stack Gives Back Safety in numbers: crowdsourcing data on nefarious IP addresses.



0コメント

  • 1000 / 1000