![]() |
中国DOS联盟-- 联合DOS 推动DOS 发展DOS --联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum |
| 游客 | 登录 | 注册 | 会员 | 搜索 | 中国DOS联盟 |
|
中国DOS联盟论坛 现在时间是 2026-08-08 02:42 |
共 48,041 主题排行 / 350,128 发帖 / 今日 3 篇 / 48,253 会员排行 |
| DOS批处理 & 脚本技术(批处理室) » 请教一个改IP+计算机名的VBS |
| 可打印版本 807 / 8 |
| 第1楼 yhshiro | 发表于 2008-04-13 10:31 |
| 初级用户 发帖 59 积分 130 | |
请教一个改IP+计算机名的VBS
我想把上面输入的机号加上LN写这下面这段注册表里面
[ Last edited by yhshiro on 2008-4-13 at 02:25 PM ] |
|
| 第2楼 slore | 发表于 2008-04-13 10:47 |
| 铂金会员 发帖 2,478 积分 5,212 | |
|
Set Oshell = CreateObject("WScript.Shell")
Set Fso = CreateObject("Scripting.FileSystemObject") Set wshshell = wscript.CreateObject("WScript.Shell") on Error Resume Next Dim IP,NetMask,Gateway,DNS1,DNS2,DNS3,DNS4,Name cmpnmnum = 3 Gateway = "192.168.10.254" DNS1 = "192.168.10.21" DNS2 = "192.168.11.21" DNS3 = "202.160.241.21" DNS4 = "98.160.10.101" inp = InputBox ("请输入机号") If (Len(inp) <> (cmpnmnum)) Then MsgBox "输入错误" oShell.run "C:\s.vbs",0, False wscript.quit End If area = "LN" area = UCase(area) num = Right(inp,cmpnmnum) If (num < 201) Then IP = "192.168.10." + CStr(CInt(num)) If (num < 101) Then NetMask = "255.255.254.0" Else NetMask = "255.255.254.0" End If Else IP = "192.168.11." + CStr(CInt(num) - 200) NetMask = "255.255.248.0" End If Name = area + CStr(num) ipxz = 1 For i = 1 To cmpnmnum ipxz = ipxz * 10 Next IPX = Asc(area) * ipxz + num ''''''''''''''''''''''''''''''''''''''''''''''''''''''' strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colNetAdapters = objWMIService.ExecQuery _ ("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE") strIPAddress = Array(IP) strSubnetMask = Array(NetMask) strGateway = Array(Gateway) strDNS = Array(DNS1,DNS2,DNS3,DNS4) For Each objNetAdapter In colNetAdapters errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask) errGateways = objNetAdapter.SetGateways(strGateway, strGatewaymetric) errDNS = objNetAdapter.SetDNSServerSearchOrder(strDNS) Next Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colComputers = objWMIService.ExecQuery _ ("Select * from Win32_ComputerSystem") For Each objComputer In colComputers ObjComputer.Rename(Name) Next Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration") objNetworkSettings.SetIPXVirtualNetworkNumber(IPX) Dim Name Name = "BM250" Oshell.RegWrite "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet003\Control\ComputerName\ActiveComputerName\ComputerName",Name,"REG_SZ" Oshell.RegWrite "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters\NV Hostname",Name,"REG_SZ" Oshell.RegWrite "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters\Hostname",Name,"REG_SZ" |
|
| 第3楼 bat-zw | 发表于 2008-04-13 11:38 |
| 金牌会员 发帖 1,276 积分 3,105 | |
|
做为VBS门外汉,我不发表任何评论,唯有一个字顶了!!!
|
|
| 第4楼 yhshiro | 发表于 2008-04-13 13:07 |
| 初级用户 发帖 59 积分 130 | |
|
对不起说错了
我要的是这样的: 在运行后弹出来的对话框里输入几号~ 然后在那几号前面加上再把那个字母和几号写入 Oshell.RegWrite "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet003\Control\ComputerName\ActiveComputerName\ComputerName",Name,"REG_SZ" 这里面 |
|
| 第5楼 abcd | 发表于 2008-04-13 13:50 |
| 银牌会员 发帖 739 积分 1,436 | |
|
是几号,还是机号?
|
|
| 第6楼 yhshiro | 发表于 2008-04-13 15:11 |
| 初级用户 发帖 59 积分 130 | |
|
是机号
|
|
| 第7楼 yhshiro | 发表于 2008-04-13 15:12 |
| 初级用户 发帖 59 积分 130 | |
|
还要在机号前面加上LN
|
|
| 第8楼 abcd | 发表于 2008-04-13 15:35 |
| 银牌会员 发帖 739 积分 1,436 | |
|
不是整个IP 吧?
num = Right(inp,cmpnmnum)是IP地址截取最后三位,是吧?? 2楼的基本可以实现了啊。 顶多的问题是:IP地址后三位不全是数字。例如:192.168.0.1等。 |
|
| 第9楼 slore | 发表于 2008-04-13 16:19 |
| 铂金会员 发帖 2,478 积分 5,212 | |
|
Dim Name
Name = "BM" & InputBox("请输入机号:","机号") |
|
|
[ 联系联盟系统管理团队 -
中国DOS联盟 -
标准版 ] Sponsored by ifanr Inc | © 2001–2023 |