Announcement

Collapse
No announcement yet.

Get subnet mask to variable

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Get subnet mask to variable

    Hi

    To cut a long story short I need to get just the subnet mask on its own to a variable I can use in DOS

    I can get the ip address on its own but need the mask also I need to feed these values to other parts of the batch file

    How would I even display the mask on its own? I have searched about and nearest I came was the netsh command.

    I need to isolate the subnet mask.

    Hope someone has a idea?

    Thanks

    Confuseis

  • #2
    You mention DOS but are you really using DOS or are you using another operating system? What OS are you using?
    Regards,
    Jeremy

    Network Consultant/Engineer
    Baltimore - Washington area and beyond
    www.gma-cpa.com

    Comment


    • #3

      Hi Its Windows 7 OS I have found the answer in the meantime. In case anyone is interested I have included it below
      for /f "tokens=2,* delims=:" %%A in ('ipconfig ^| find "Subnet"') do set subnet=%%A set subnet=%subnet:~1% echo %subnet% Thanks Confuseis

      Comment


      • #4
        Thanks for sharing!

        For anyone that needs it, here it is in the code tags:
        Code:
        for /f "tokens=2,* delims=:" %%A in ('ipconfig ^| find "Subnet"') do set subnet=%%A
        set subnet=%subnet:~1%
        echo %subnet%
        Last edited by JeremyW; 9th September 2015, 17:50.
        Regards,
        Jeremy

        Network Consultant/Engineer
        Baltimore - Washington area and beyond
        www.gma-cpa.com

        Comment

        Working...
        X