VBS脚本修改
OnErrorResumeNextConstMASK="255.255.255.0"num=0num=InPutBox("请输入本机号","输入")IfTrim(num)...
On Error Resume Next
Const MASK="255.255.255.0"
num=0
num=InPutBox("请输入本机号","输入")
If Trim(num) = "" Then
MsgBox "您没输入值,退出。"
: WScript.quit
End If
If num=0 or num>255 or num <1 then MsgBox "输入有错误,退出。" : WScript.quit
num=Cint(num)
IP="10.10.1."&num&"0"
num=Cstr(num)
if num <10 then
num="0"&num
end if
if num>9 then
num=num
end if
COMPUTER_NAME="DC"&num
wscript.echo COMPUTER_NAME &" "& IP
dim fso,wshell,ipobj,ComputerObj,Nobj,Adapter,LINK_INDEX,LINK_NAME
Set Adapter=GetObject("winmgmts:").InstancesOf("WIN32_NetworkAdapter")
For Each link In Adapter
If mid(link.NetConnectionID,1,4)="本地连接" And InStr(1,link.name,"TV/Video") =0 Then '这样处理因为有时叫本地连接1.2.3...然后再除掉装摄像头后的虚拟网卡
LINK_NAME=link.NetConnectionID
LINK_INDEX=link.index
End If
Next
set wshell=CreateObject("WScript.Shell")
Set fso=CreateObject("Scripting.FileSystemObject")
Set nobj=GetObject("winmgmts:\\.\root\cimv2")
Set ComputerObj=nobj.ExecQuery("select * from Win32_ComputerSystem")
Set ipobj=nobj.execQuery("select * from WIN32_NETWORKADAPTERCONFIGURATION where index="&CStr(LINK_INDEX))
for each co in computerobj
co.rename COMPUTER_NAME '修改计算机名
next
for each IO in ipobj
IO.EnableStatic Array(IP),Array(MASK) '修改IP地址
IO.SetGateWays Array(GateWay) '修改默认网关
IO.SetDNSServerSearchOrder Array(DNS1,DNS2) '修改DNS
next
----------------
修改上面的代码,在输入数值不满足条件时可以重新输入而不是退出.最好能做到必须输入成功才可以退出.
If num=0 or num>255 or num <1
这一段应该是
If num=0 or num>25 or num <1 展开
Const MASK="255.255.255.0"
num=0
num=InPutBox("请输入本机号","输入")
If Trim(num) = "" Then
MsgBox "您没输入值,退出。"
: WScript.quit
End If
If num=0 or num>255 or num <1 then MsgBox "输入有错误,退出。" : WScript.quit
num=Cint(num)
IP="10.10.1."&num&"0"
num=Cstr(num)
if num <10 then
num="0"&num
end if
if num>9 then
num=num
end if
COMPUTER_NAME="DC"&num
wscript.echo COMPUTER_NAME &" "& IP
dim fso,wshell,ipobj,ComputerObj,Nobj,Adapter,LINK_INDEX,LINK_NAME
Set Adapter=GetObject("winmgmts:").InstancesOf("WIN32_NetworkAdapter")
For Each link In Adapter
If mid(link.NetConnectionID,1,4)="本地连接" And InStr(1,link.name,"TV/Video") =0 Then '这样处理因为有时叫本地连接1.2.3...然后再除掉装摄像头后的虚拟网卡
LINK_NAME=link.NetConnectionID
LINK_INDEX=link.index
End If
Next
set wshell=CreateObject("WScript.Shell")
Set fso=CreateObject("Scripting.FileSystemObject")
Set nobj=GetObject("winmgmts:\\.\root\cimv2")
Set ComputerObj=nobj.ExecQuery("select * from Win32_ComputerSystem")
Set ipobj=nobj.execQuery("select * from WIN32_NETWORKADAPTERCONFIGURATION where index="&CStr(LINK_INDEX))
for each co in computerobj
co.rename COMPUTER_NAME '修改计算机名
next
for each IO in ipobj
IO.EnableStatic Array(IP),Array(MASK) '修改IP地址
IO.SetGateWays Array(GateWay) '修改默认网关
IO.SetDNSServerSearchOrder Array(DNS1,DNS2) '修改DNS
next
----------------
修改上面的代码,在输入数值不满足条件时可以重新输入而不是退出.最好能做到必须输入成功才可以退出.
If num=0 or num>255 or num <1
这一段应该是
If num=0 or num>25 or num <1 展开
1个回答
展开全部
On Error Resume Next
Const MASK="255.255.255.0"
num=0
do
num=InPutBox("请输入本机号","输入")
If Trim(num) = "" Then
MsgBox "您没输入值,请重新输入。"
elseIf num=0 or num>25 or num <1 then
MsgBox "输入有错误,请重新输入。"
else exit do
end if
loop
num=Cint(num)
IP="10.10.1."&num&"0"
num=Cstr(num)
if num <10 then
num="0"&num
end if
if num>9 then
num=num
end if
COMPUTER_NAME="DC"&num
wscript.echo COMPUTER_NAME &" "& IP
dim fso,wshell,ipobj,ComputerObj,Nobj,Adapter,LINK_INDEX,LINK_NAME
Set Adapter=GetObject("winmgmts:").InstancesOf("WIN32_NetworkAdapter")
For Each link In Adapter
If mid(link.NetConnectionID,1,4)="本地连接" And InStr(1,link.name,"TV/Video") =0 Then '这样处理因为有时叫本地连接1.2.3...然后再除掉装摄像头后的虚拟网卡
LINK_NAME=link.NetConnectionID
LINK_INDEX=link.index
End If
Next
set wshell=CreateObject("WScript.Shell")
Set fso=CreateObject("Scripting.FileSystemObject")
Set nobj=GetObject("winmgmts:\\.\root\cimv2")
Set ComputerObj=nobj.ExecQuery("select * from Win32_ComputerSystem")
Set ipobj=nobj.execQuery("select * from WIN32_NETWORKADAPTERCONFIGURATION where index="&CStr(LINK_INDEX))
for each co in computerobj
co.rename COMPUTER_NAME '修改计算机名
next
for each IO in ipobj
IO.EnableStatic Array(IP),Array(MASK) '修改IP地址
IO.SetGateWays Array(GateWay) '修改默认网关
IO.SetDNSServerSearchOrder Array(DNS1,DNS2) '修改DNS
next
试试看 ...我这里测试 可以
我的博客 www.52sky.org
Const MASK="255.255.255.0"
num=0
do
num=InPutBox("请输入本机号","输入")
If Trim(num) = "" Then
MsgBox "您没输入值,请重新输入。"
elseIf num=0 or num>25 or num <1 then
MsgBox "输入有错误,请重新输入。"
else exit do
end if
loop
num=Cint(num)
IP="10.10.1."&num&"0"
num=Cstr(num)
if num <10 then
num="0"&num
end if
if num>9 then
num=num
end if
COMPUTER_NAME="DC"&num
wscript.echo COMPUTER_NAME &" "& IP
dim fso,wshell,ipobj,ComputerObj,Nobj,Adapter,LINK_INDEX,LINK_NAME
Set Adapter=GetObject("winmgmts:").InstancesOf("WIN32_NetworkAdapter")
For Each link In Adapter
If mid(link.NetConnectionID,1,4)="本地连接" And InStr(1,link.name,"TV/Video") =0 Then '这样处理因为有时叫本地连接1.2.3...然后再除掉装摄像头后的虚拟网卡
LINK_NAME=link.NetConnectionID
LINK_INDEX=link.index
End If
Next
set wshell=CreateObject("WScript.Shell")
Set fso=CreateObject("Scripting.FileSystemObject")
Set nobj=GetObject("winmgmts:\\.\root\cimv2")
Set ComputerObj=nobj.ExecQuery("select * from Win32_ComputerSystem")
Set ipobj=nobj.execQuery("select * from WIN32_NETWORKADAPTERCONFIGURATION where index="&CStr(LINK_INDEX))
for each co in computerobj
co.rename COMPUTER_NAME '修改计算机名
next
for each IO in ipobj
IO.EnableStatic Array(IP),Array(MASK) '修改IP地址
IO.SetGateWays Array(GateWay) '修改默认网关
IO.SetDNSServerSearchOrder Array(DNS1,DNS2) '修改DNS
next
试试看 ...我这里测试 可以
我的博客 www.52sky.org
AiPPT
2024-09-19 广告
2024-09-19 广告
随着AI技术的飞速发展,如今市面上涌现了许多实用易操作的AI生成工具1、简介:AiPPT: 这款AI工具智能理解用户输入的主题,提供“AI智能生成”和“导入本地大纲”的选项,生成的PPT内容丰富多样,可自由编辑和添加元素,图表类型包括柱状图...
点击进入详情页
本回答由AiPPT提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询