国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > VBScript > 正文

使用腳本自動修改ip設置

2020-07-26 12:15:17
字體:
來源:轉載
供稿:網友
vbs腳本的功能非常強大, 管理系統簡單方便!下面的腳本win2000和winxp都可以使用,win2003沒有測試過, 應該也沒有問題。如果需要經常切換網關,或是ip,這個腳本是最方便的了。稍微修改一下甚至可以做到1分鐘變一次ip。

復制代碼 代碼如下:

@Echo Off
TITLE  武林網ip設置器

:start
CLS
COLOR 2f
:: 使用COLOR命令對控制臺輸出顏色進行更改
mode con cols=56 lines=20
:: MODE語句為設定窗體的寬和高
:sc_main
echo       -------------------------------------------
echo.&echo.
echo             0.192.168.0.99 & echo.
echo             1.192.168.1.99 & echo.
echo             q.退出 & echo.&echo.&echo.&echo.&echo.&echo.

set "select="
set/p select= 輸入數字,按回車繼續 :
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 正在設置中,請稍候
Netsh interface IP Set Address "本地連接" Static 192.168.0.99 255.255.255.0 192.168.0.1 1
Netsh interface IP set dns "本地連接" static 192.168.0.1 primary
echo 設置成功 192.168.0.99
PAUSE >nul
Goto sc_main
:sc_ip1
cls
echo 正在設置中,請稍候
Netsh interface IP Set Address "本地連接" Static 192.168.1.99 255.255.255.0 192.168.1.1 1
Netsh interface IP set dns "本地連接" static 192.168.1.1 primary
echo 設置成功 192.168.1.99
PAUSE >nul
Goto sc_main

vbs修改ip

復制代碼 代碼如下:

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      '保持原來的ip,如果需要修改ip為192.168.0.200:strIPAddress = Array("192.168.0.200")
strSubnetMask = Array("255.255.255.0")
strGateway = Array("192.168.0.254")     '修改網關為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      '只修改第一個網卡的設置
Next

VBS修改IP

復制代碼 代碼如下:

'VBS修改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
'機器名頭
head="B"
'ip頭
iphead="192.168.131"
ipgate="192.168.131"

dim i
i=inputbox("輸入機器序號(2-254)")
if i="" then
msgbox "Error: 序號不正確!"
else
dim shell
set shell = CreateObject("WScript.Shell")

'修改計算機名
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"
'修改IP
shell.run "netsh interface ip set address 本地連接 static " & iphead & "." & i & " 255.255.255.0 " & ipgate & ".252 1"
'msgbox "OK"
        shell.run "netsh interface ip set address 本地連接 static " & iphead & "." & i & " 255.255.255.0 " & ipgate & ".252 1"
'msgbox "OK"
        shell.run "netsh interface ip set address 本地連接 static " & iphead & "." & i & " 255.255.255.0 " & ipgate & ".252 1"
'msgbox "OK"
end if

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 沛县| 静海县| 藁城市| 遂平县| 顺义区| 沙坪坝区| 九龙县| 府谷县| 高雄市| 河西区| 上林县| 新蔡县| 自治县| 石屏县| 郁南县| 忻州市| 宜章县| 科技| 大同市| 广东省| 广丰县| 佛冈县| 大渡口区| 台中县| 汉沽区| 额济纳旗| 广西| 中江县| 高要市| 乐平市| 海兴县| 泸水县| 杭锦旗| 丽水市| 横峰县| 定兴县| 措勤县| 庆云县| 台中县| 修水县| 班戈县|