Virajsinh

Set Static IP Address Using Batch File ( .bat ) in Window

Dec 15th, 2021 (edited)
1,016
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ECHO off
  2. cls
  3. :start
  4. ECHO.
  5. ECHO  ----------------------------------------------
  6. ECHO  Set Static IPv4 Address And IP Address Info
  7. ECHO  ----------------------------------------------
  8. ECHO  1. GTPL Broadband : 198.168.2.48
  9. ECHO  2. You Broadband  : 192.168.31.48
  10. ECHO  3. GTPL Broadband Custom IP Set
  11. ECHO  4. You Broadband Custom IP Set
  12. ECHO  5. Show Internet Interface
  13. ECHO  6. Show IP Address
  14. ECHO  7. Set Automatic IP DHCP
  15. ECHO  8. Exit
  16. ECHO  ----------------------------------------------
  17. ECHO  #. Created By VeeRa
  18. ECHO  ----------------------------------------------
  19. ECHO  NOTE : Only For "Ethernet"
  20. ECHO  ----------------------------------------------
  21. set choice=
  22. set /p choice= Enter Choice :
  23. if not '%choice%'=='' set choice=%choice:~0,1%
  24. if '%choice%'=='1' goto gtpl_b
  25. if '%choice%'=='2' goto you_b
  26. if '%choice%'=='3' goto gtpl_b_custom
  27. if '%choice%'=='4' goto you_b_custom
  28. if '%choice%'=='5' goto show_net
  29. if '%choice%'=='6' goto show_ip
  30. if '%choice%'=='7' goto set_auto
  31. if '%choice%'=='8' goto exit
  32. ECHO "%choice%" is not valid, try again
  33. ECHO.
  34.     goto start
  35.  
  36.     :gtpl_b
  37.         ECHO:
  38.         ECHO GTPL Broadband Static IP Set
  39.         ECHO:
  40.  
  41.         set IP=192.168.2.48
  42.         set Sub_Mask=255.255.255.0
  43.         set D_Gate=192.168.2.1
  44.         set DNS=8.8.8.8
  45.         set DNS2=4.2.2.2
  46.  
  47.         netsh interface ipv4 set address name="Ethernet" static %IP% %Sub_Mask% %D_Gate%
  48.         netsh interface ipv4 set dns name="Ethernet" static %DNS% primary validate=no
  49.         netsh interface ipv4 add dns name="Ethernet" %DNS2% index=2 validate=no
  50.         netsh int ip show config name="Ethernet"
  51.  
  52.     goto start
  53.     :you_b
  54.         ECHO:
  55.         ECHO You Broadband Static IP Set
  56.         ECHO:
  57.  
  58.         set IP=192.168.31.48
  59.         set Sub_Mask=255.255.255.0
  60.         set D_Gate=192.168.31.1
  61.         set DNS=8.8.8.8
  62.         set DNS2=4.2.2.2
  63.  
  64.         netsh interface ipv4 set address name="Ethernet" static %IP% %Sub_Mask% %D_Gate%
  65.         netsh interface ipv4 set dns name="Ethernet" static %DNS% primary validate=no
  66.         netsh interface ipv4 add dns name="Ethernet" %DNS2% index=2 validate=no
  67.         netsh int ip show config name="Ethernet"
  68.  
  69.     goto start
  70.     :show_net
  71.         netsh interface show interface
  72.  
  73.     goto start
  74.     :show_ip
  75.         netsh int ip show config name="Ethernet"
  76.     goto start
  77.     :gtpl_b_custom
  78.         ECHO Example : 192.168.2.XXX
  79.         set /p gtpl_ip= Enter IP Address :
  80.         set IP=%gtpl_ip%
  81.         set Sub_Mask=255.255.255.0
  82.         set D_Gate=192.168.2.1
  83.         set DNS=8.8.8.8
  84.         set DNS2=4.2.2.2
  85.  
  86.         netsh interface ipv4 set address name="Ethernet" static %IP% %Sub_Mask% %D_Gate%
  87.         netsh interface ipv4 set dns name="Ethernet" static %DNS% primary validate=no
  88.         netsh interface ipv4 add dns name="Ethernet" %DNS2% index=2 validate=no
  89.         netsh int ip show config name="Ethernet"
  90.     goto start
  91.     :you_b_custom
  92.         ECHO Example : 192.168.31.XXX
  93.         set /p you_ip= Enter IP Address :
  94.         set IP=%you_ip%
  95.         set Sub_Mask=255.255.255.0
  96.         set D_Gate=192.168.31.1
  97.         set DNS=8.8.8.8
  98.         set DNS2=4.2.2.2
  99.  
  100.         netsh interface ipv4 set address name="Ethernet" static %IP% %Sub_Mask% %D_Gate%
  101.         netsh interface ipv4 set dns name="Ethernet" static %DNS% primary validate=no
  102.         netsh interface ipv4 add dns name="Ethernet" %DNS2% index=2 validate=no
  103.         netsh int ip show config name="Ethernet"
  104.     goto start
  105.     :set_auto
  106.         netsh interface ip set address "Ethernet" dhcp
  107.         netsh interface ipv4 set dns name="Ethernet" dhcp
  108.         netsh int ip show config name="Ethernet"
  109.     goto start
  110.     :exit
  111.     goto end
  112.     :end
  113. pause
Add Comment
Please, Sign In to add comment