In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article focuses on "how to use vbs scripts to automatically modify ip settings", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to use vbs scripts to automatically modify ip settings.
The code is as follows:
@ Echo Off
TITLE ip setter
: start
CLS
COLOR 2f
: use the COLOR command to change the console output color
Mode con cols=56 lines=20
:: MODE statement sets the width and height of the form
: sc_main
Echo
Echo.&echo.
Echo 0.192.168.0.99 & echo.
Echo 1.192.168.1.99 & echo.
Echo q. Quit & echo.&echo.&echo.&echo.&echo.&echo.
Set "select="
Set/p select= enter a number and press enter to continue:
If "% select%" = = "0" (goto sc_ip0)
If "% select%" = = "1" (goto sc_ip1)
If "% select%" = = "Q" (goto sc_exit)
: sc_exit
Exit
Goto: eof
: sc_ip0
Cls
Echo is being set up, please wait a moment
Netsh interface IP Set Address "Local connection" Static 192.168.0.99 255.255.255.0 192.168.0.1 1
Netsh interface IP set dns "Local connection" static 192.168.0.1 primary
Echo set up successfully 192.168.0.99
PAUSE > nul
Goto sc_main
: sc_ip1
Cls
Echo is being set up, please wait a moment
Netsh interface IP Set Address Local connection Static 192.168.1.99 255.255.255.0 192.168.1.1 1
Netsh interface IP set dns "Local connection" static 192.168.1.1 primary
Echo set up successfully 192.168.1.99
PAUSE > nul
Goto sc_main
Vbs modifies ip
The code is as follows:
Changeip.vbsstrComputer = "."
Set objWMIService = GetObject ("winmgmts:\\" & strComputer & "\ root\ cimv2")
Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
For Each objNetAdapter in colNetAdapters
Sip=objNetAdapter.IPAddress
StrIPAddress = sip 'keep the original ip, if you need to change the ip to 192.168.0.200:strIPAddress = Array ("192.168.0.200")
StrSubnetMask = Array ("255.255.255.0")
StrGateway = Array ("192.168.0.254") 'modify the gateway to 192.168.0.254
StrGatewayMetric = Array (1)
ErrEnable = objNetAdapter.EnableStatic (strIPAddress, strSubnetMask)
ErrGateways = objNetAdapter.SetGateways (strGateway, strGatewaymetric)
If errEnable = 0 Then
WScript.Echo "The IP address has been changed."
Else
WScript.Echo "The IP address could not be changed."
End If
Exit for 'only modifies the settings of the first network card
Next
VBS modifies IP
The code is as follows:
'VBS modifies IP
Function transh (s)
If isnumeric (s) then
If len (s) = 1 then
Transh= "00" & s
Elseif len (s) = 2 then
Transh= "0" & s
Elseif len (s) = 3 then
Transh=s
End if
Else
Transh= ""
End if
End function
Dim head
'Machine name
Head= "B"
'IP head
Iphead= "192.168.131"
Ipgate= "192.168.131"
Dim i
I=inputbox ("enter machine serial number (2-254)")
If I = "" then "
Msgbox "Error: incorrect serial number!"
Else
Dim shell
Set shell = CreateObject ("WScript.Shell")
'modify the computer name
Shell.RegWrite "HKLM\ SYSTEM\ CurrentControlSet\ Control\ ComputerName\ ComputerName\ ComputerName", head & transh (I), "REG_SZ"
Shell.RegWrite "HKLM\ SYSTEM\ CurrentControlSet\ Services\ Tcpip\ Parameters\ NV Hostname", head & transh (I), "REG_SZ"
Shell.RegWrite "HKLM\ SYSTEM\ CurrentControlSet\ Services\ Tcpip\ Parameters\ Hostname", head & transh (I), "REG_SZ"
'modify IP
Shell.run "netsh interface ip set address Local connection static" & iphead & "." & I & "255.255.255.0" & ipgate & ".2521"
'msgbox "OK"
Shell.run "netsh interface ip set address Local connection static" & iphead & "." & I & "255.255.255.0" & ipgate & ".2521"
'msgbox "OK"
Shell.run "netsh interface ip set address Local connection static" & iphead & "." & I & "255.255.255.0" & ipgate & ".2521"
'msgbox "OK"
End if
At this point, I believe you have a deeper understanding of "how to use vbs scripts to automatically modify ip settings". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue 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.