Win batch process automatically set IP address

Source: Internet
Author: User

@echo off

REM select=1, Nic IP will be set to 172.16.200.34,select=2, Nic IP will be set to 192.168.0.5

Ping-n 2 192.168.0.254 && set select=2 | | Set Select=1

REM Get network card name

for/f "skip=4 tokens=3* delims="%%i in (' ipconfig ') do (

Set adapter=%%i

Goto out

)

: Out

Set adapter=%adapter::=%

If%select%==1 (

netsh int ip set address name= "%adapter%" static 172.16.200.34 255.255.255.0 172.16.200.1 1

netsh int ip set DNS name= "%adapter%" static 202.102.224.68 Primary

netsh int ip add dns name= "%adapter%" 202.102.227.68 index=2

) Else (

netsh int ip set address name= "%adapter%" static 192.168.0.5 255.255.255.0 192.168.0.254 1

)

echo settings complete, press any key to exit!

Pause >nul 2>nul

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.