title: How can I verify that a string is a valid IPv4 or IPv6 address in batch?
body: <p>I need to verify if a string is a valid IPv4 or IPv6 address in a Batch script, but apparently Batch doesn't have an easy way to parse an IP address.</p>
  <p>How can I do this in Batch <strong>without</strong> using external tools? By &quot;external tools&quot; I mean things that aren't already present on a normal Windows installation.</p>
  <p>By &quot;valid IPv4 or IPv6 address&quot; I mean a string that is in the format of an IP address, false positives with strings like <code>999.999.999.999</code> are OK (even if some basic filtering is welcome). As a rule of thumb, a solution should at least be able to distinguish an error message from an address.</p>
  <p>I know that a <a href="https://stackoverflow.com/questions/20299266/ip-verification-in-batch-script-first-match-by-findstr-secondly-verify-by-for">similar question</a> already exists, but that question doesn't take IPv6 into consideration and it's more strict in its definition of &quot;valid IPv4 address&quot; (something like <code>999.999.999.999</code> isn't acceptable).</p>