使用脚本自动修改ip设置

2019-01-15 14:56:11于丽

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 "HKLMSYSTEMCurrentControlSetControlComputerNameComputerNameComputerName", head & transh(i) ,"REG_SZ"
shell.RegWrite "HKLMSYSTEMCurrentControlSetServicesTcpipParametersNV Hostname", head & transh(i) ,"REG_SZ"
shell.RegWrite "HKLMSYSTEMCurrentControlSetServicesTcpipParametersHostname", 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

您可能感兴趣的文章:

bat 选项之修改ip的脚本代码(让用户可以选择操作并进行判断执行)Windows下用命令行修改IP地址的方法详解(附批处理文件)利用vbs自动修改ip的代码dos环境下修改ip地址用bat文件修改ip