Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Batch modify IP

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Because of frequent business trips, I find it very troublesome to modify IP every time. Then I thought that I could modify the IP address in batches. By checking the data and testing, I finally found a batch that can modify IP under win10 (which needs to be run with administrator privileges), but it is not perfect.

ECHO OFFREM QBFC Project Options BeginREM HasVersionInfo: NoREM Companyname: REM Productname: REM Filedescription: REM Copyrights: REM Trademarks: REM Originalname: REM Comments: REM Productversion: 0. 0. 0. 0REM Fileversion: 0. 0. 0. 0REM Internalname: REM Appicon: 2.icoREM QBFC Project Options EndECHO ON@echo off:: BatchGotAdmin:-- automatically get administrator privileges, temporary REM-- > Check for permissions > nul 2 > & 1 "% SYSTEMROOT%\ system32\ cacls.exe"% SYSTEMROOT%\ system32\ config\ system" REM-- > If error flag set, we do not have admin. If'% errorlevel%' NEQ'0' (echo Requesting administrative privileges... Goto UACPrompt) else (goto gotAdmin): UACPrompt echo Set UAC = CreateObject^ ("Shell.Application" ^) > "% temp%\ getadmin.vbs" echo UAC.ShellExecute "% ~ s0", "runas" 1 > > "% temp%\ getadmin.vbs"% temp%\ getadmin.vbs" exit / B: gotAdmin if exist "% temp%\ getadmin.vbs" (del "% temp%\ getadmin.vbs") pushd "% CD%" CD / D "% dp0":--

Color 1

Set / p choice= 1. Set the company IP 2.IP to automatically get 3. End 4. Test your selections:

Echo.

If "% choice%" = = "1" goto ip1

If "% choice%" = = "2" goto ip2

If "% choice%" = = "3" goto end

If "% choice%" = = "4" goto test

Goto main

: ip1

Echo IP automatic setting begins.

Echo.

Echo is setting IP and subnet mask

Cmd / c netsh interface ip set address name= "Ethernet" source=static addr=192.168.62.178 mask=255.255.255.0 gateway=192.168.62.1 gwmetric=1

Echo is setting up the DNS server

Cmd / c netsh interface ip set dnsservers "Ethernet" static 114.114.114.114 primary

Netsh interface ip add dnsservers "Ethernet" 8.8.8.8 index=2

Echo setup complete

Pause

Exit

If errorlevel 2 goto main

If errorlevel 1 goto end

: ip2

Color 2

Echo IP automatic setting begins.

Echo.

Echo automatically obtains the IP address.

Netsh interface ip set address name = "Ethernet" source = dhcp

Echo automatically gets the DNS server.

Netsh interface ip set dns name = "Ethernet" source = dhcp

@ rem sets the automatic acquisition of IP

Echo setup complete

Pause

Exit

If errorlevel 2 goto main

If errorlevel 1 goto end

: test

Netsh inte***ce ip set address name = "Ethernet" source = dhcp

Netsh inte***ce ip set dns name = "Ethernet" source = dhcp

Netsh inte***ce ip set wins name = "Ethernet" source = dhcp

CHOICE / C YN / M "press Y to exit and N to return to the menu."

If errorlevel 2 goto main

If errorlevel 1 goto end

: end

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report