In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces how to write IP address setting switch batch processing, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
Fixed an error in extracting the name of a network connection because of the previous use of spaces as delimiters in FOR
If the network connection is named "Local connection 2", it will only be recognized as "Local connection", causing the setting to fail.
Has now been corrected
Description: 1. You can choose the network connection to be set.
2. You can set the fixed IP manually or obtain it automatically through DHCP
3. Multiple groups of MAC and IP corresponding data can be preset in batch processing, and the corresponding IP can be quickly queried when the private network is bound with MAC.
4. DNS settings provide four types of data (China Telecom, China Unicom / China Netcom, China Mobile / China Railcom, intranet gateway)
DNS is the data of Fuzhou area. Please change it to DNS of local broadband operators.
5. Add another function: after setting up, you can choose whether to add native MAC and IP data to this batch for automatic identification next time.
The batch code is as follows:
The code is as follows:
@ title IP address setting toggle batch
@ echo off & setlocal enabledelayedexpansion
If exist "% windir%\ system32\ slmgr.vbs" (
Echo.&echo this batch must be run as an administrator in VISTA and WIN7
Echo.&echo, please check whether the title bar information of the batch window begins with "administrator:"
If echo.&echo meets the above conditions, you can press any key to continue, otherwise, please quit the batch and rerun as an administrator
Pause > nul
)
Set nasty 0
For / f "delims=:"% an in ('ipconfig/ all ^ | findstr / I / b / c: "Ethernet adapter"') do (set / a networked instrument 1 sets networked instruments 17!)
Set nasty 0
For / f "tokens=2 delims=:"% an in ('ipconfig/ all ^ | findstr / I / c: "Description"') do (set / a)
Set nasty 0
For / f "tokens=2 delims=:"% an in ('ipconfig/ all ^ | findstr / I / c: "Physical Address"') do (set / a naughty cake%% a)
: net
Echo.&echo Please select the network link that you want to set up on your local computer:
For / l% an in. Do (
Echo.
Echo a -! net%%a! -! netcard%%a!
Echo MAC address:! MAC%%a!
)
Echo.&set num=&set / p num= Please enter the serial number and enter to select:
Cls
If defined net%num% (set Networknet% numm% MAC% Num%: =! & set MACV MACGRON 0Phone17!) Else (the serial number entered by echo.&echo is incorrect, please select again! & goto: net)
: lib
Set MASK=255.255.255.0
Set GATE=192.168.0.1
Cls&echo.&echo current! NET! The MAC is! MAC!
For / f "tokens=2 delims= []" an in ('findstr / I "! MAC!" 0') do set IP=%%a
If defined IP (
Set inbat=1
Echo.&echo found the corresponding data in the batch database
Echo.&echo IP:! IP!
Echo.&echo subnet mask:! MASK!
Echo.&echo Gateway:! GATE!
Echo.&set / p IP= if you need to change the IP data, enter and enter manually. If you take the default value, enter directly:
Echo.&set / p MASK= if you need to change the subnet mask data, enter and enter manually. If you take the default value, enter directly:
Echo.&set / p GATE= if you need to change the gateway data, enter and enter manually. If you take the default value, enter directly:
Goto: isp
) else (
Set inbat=0
Echo.&echo did not find the corresponding IP in the batch database. Please manually select the IP setting method
Goto: lan
)
: lan
The current web links to be set by echo.&echo are:
Echo.&echo! NET! -! Netcard% Num%!
Echo.&echo, please select the IP setting method:
Echo.&echo 1-manually set fixed IP
Echo.&echo 2-DHCP automatic acquisition
Echo.&set choose=&set / p choose= Please enter the serial number and enter to select:
Cls
If% choose% equ 1 goto: set
If% choose% equ 2 goto: dhcp
The serial number entered by echo.&echo is incorrect, please select again! & goto: lan
: set
Set IP=192.168.0.9
The default IP of cls&echo.&echo is! IP!. If you need to change it, enter and enter manually. If you take the default value, enter directly:
Echo.&set / p IP=
The default subnet mask of cls&echo.&echo is! MASK!. If you need to change it, enter it manually and press enter. If you take the default, enter directly:
Echo.&set / p MASK=
The default gateway of cls&echo.&echo is! GATE!. If you need to change it, enter and enter manually. If you take the default value, enter directly:
Echo.&set / p GATE=
: isp
Cls&echo.&echo Please select the broadband line corresponding to DNS (Fuzhou area):
Echo.&echo 1-China Telecom
Echo.&echo 2-China Unicom / China Netcom
Echo.&echo 3-China Mobile / China Railcom
Echo.&echo 4-Intranet gateway% GATE%
Echo.&set isp=&set / p isp= Please enter the serial number and enter to select:
If% isp% equ 1 (call: 10000&goto: doset)
If% isp% equ 2 (call: 10010&goto: doset)
If% isp% equ 3 (call: 10086&goto: doset)
If% isp% equ 4 (set DNS1=%GATE%&goto: doset)
The serial number entered by echo.&echo is incorrect, please select again! & goto: isp
: doset
Cls&echo.&echo is setting up NET%, IP address is IP%, please wait.
Netsh interface ip set address name= "NET%" static IP% MASK% GATE% 1 > nul
Netsh interface ip set dns name= "NET%" static DNS1% > nul
If defined DNS2 netsh interface ip add dns name= "NET%" DNS2% 2 > nul
Goto: end
: dhcp
Cls&echo.&echo is setting up NET%, automatically get IP and DNS, please wait.
Netsh interface ip set address name= "NET%" DHCP > nul 2 > nul
Netsh interface ip set dns name= "NET%" DHCP > nul 2 > nul
Goto: end
: end
Cls
Ipconfig/all
Echo.&echo has been set up. The current IP information is as above. Please check it carefully.
If! inbat! Equ 0 (
Echo.&echo enter Y and enter to add native MAC and IP data to this batch for automatic identification next time
If echo.&set / p addbat= does not add data, enter directly and exit:
If / i! addbat! Equ Y echo > > 0 [! MAC!]! IP!
) else (pause > nul)
Exit
* * *
:: the following DNS is for use in Fuzhou area only. Please change it to the DNS of each broadband operator in this area.
: 10000
Set DNS1=218.85.152.99
Set DNS2=218.85.157.99
Goto: eof
: 10010
Set DNS1=58.22.96.66
Set DNS2=218.104.128.106
Goto: eof
: 10086
Set DNS1=222.47.29.93
Set DNS2=222.47.62.142
Goto: eof
* * *
The host MAC and IP are assigned the corresponding database. When the private network is bound with MAC, you can quickly query the corresponding IP.
You can add it according to the example format ([MAC address] IP address), and each group of data has a separate line.
Example:
[11-22-33-44-55-66] 192.168.0.1
* * *
Thank you for reading this article carefully. I hope the article "how to write IP address setting switching batches" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.