CMD command to set Internet Protocol Version 4 (TCP/IPv4)  


  1. Posts : 25
    Multiple
       #1

    CMD command to set Internet Protocol Version 4 (TCP/IPv4)


    Hello all,
    in Win10 I have my Ethernet interface which is normally set to "Obtain IP address automatically" and "Obtain DNS server address automatically".
    To connect it to another PC via Ethernet cable to transfer files, I was instructed to use the IP address 192.168.0.2 and subset mask 255.255.255.0.
    It works.
    Then, when transfer has accomplished, I have to open again the Internet Protocol Version 4 (TCP/IPv4) and select "Obtain IP address automatically" to go on Internet after having connected the cable again to the router.
    Well, I would like to create a batch that replicates the above settings.
    Any idea to avoid to re-invent the wheel?
    Thanks!
      My Computer


  2. Posts : 1,565
    Windows 10 Pro x64 22H2
       #2

    Do you insist on batch script or would PowerShell script be fine for you as well?
      My Computer


  3. Posts : 14,944
    Windows 10 Home x64 Version 22H2 Build 19045.2965
       #3

    This would be a netsh command in a batch file.

    See Configure Static IP with the Netsh Command-Line Utility - TechGenix
    and there might be other useful guides in these search results

    Double-check everything anybody tells you about netsh - use its Help for this. Netsh in Windows 10 is significantly different from its earlier versions [a lot of online advice fails to warn you about this].
    The TechGenix link is from a decade ago so you 'd definitely want to check that.
    Enter this command after adjusting it for a convenient folder path of your own.
    Code:
    netsh interface ipv4 /? >D:\Desktop\NetshInterfaceIpv4.txt
    and then probably
    Code:
    netsh interface ipv4 add address /? >D:\Desktop\NetshInterfaceIpv4Add.txt
    It's all rather tedious.

    Denis
      My Computer


  4. Posts : 25
    Multiple
    Thread Starter
       #4

    zebal said:
    Do you insist on batch script or would PowerShell script be fine for you as well?
    No, I haven't any prejudice to use powershell if solves.

    - - - Updated - - -

    Try3 said:
    This would be a netsh command in a batch file.

    See Configure Static IP with the Netsh Command-Line Utility - TechGenix
    and there might be other useful guides in these search results

    Double-check everything anybody tells you about netsh - use its Help for this. Netsh in Windows 10 is significantly different from its earlier versions [a lot of online advice fails to warn you about this].
    The TechGenix link is from a decade ago so you 'd definitely want to check that.
    Enter this command after adjusting it for a convenient folder path of your own.
    Code:
    netsh interface ipv4 /? >D:\Desktop\NetshInterfaceIpv4.txt
    and then probably
    Code:
    netsh interface ipv4 add address /? >D:\Desktop\NetshInterfaceIpv4Add.txt
    It's all rather tedious.

    Denis
    Thanks to the people who replied to me.
    I already wrote a CMD to set the IP address and subset I need.
    The point is to find a way to "Obtain IP address automatically" .
    I read a lot of posts but I didn't find a way to achieve that goal.
      My Computer


  5. Posts : 14,944
    Windows 10 Home x64 Version 22H2 Build 19045.2965
       #5

    Cirus said:
    The point is to find a way to "Obtain IP address automatically" .
    Then read the netsh Help files to find out how to do it.

    Denis
      My Computer


  6. Posts : 25
    Multiple
    Thread Starter
       #6

    Cirus said:
    No, I haven't any prejudice to use powershell if solves.

    - - - Updated - - -



    Thanks to the people who replied to me.
    I already wrote a CMD to set the IP address and subset I need.
    The point is to find a way to "Obtain IP address automatically" .
    I read a lot of posts but I didn't find a way to achieve that goal.
    SOLVED The CMD command is
    netsh interface ipv4 set address name="Interface_Name" source=dhcp
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 06:19.
Find Us




Windows 10 Forums