十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
这篇文章给大家分享的是有关怎么使用vbs脚本获取网卡MAC,CPUID,硬盘序列号的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。
创新互联长期为上千多家客户提供的网站建设服务,团队从业经验10年,关注不同地域、不同群体,并针对不同对象提供差异化的产品和服务;打造开放共赢平台,与合作伙伴共同营造健康的互联网生态环境。为涡阳企业提供专业的做网站、网站建设,涡阳网站改版等技术服务。拥有10年丰富建站经验和众多成功案例,为您定制开发。这里先给大家分享一个分配静态ip地址的代码
' Assign a Static IP Address strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colNetAdapters = objWMIService.ExecQuery _ ("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE") strIPAddress = Array("192.168.6.98") strSubnetMask = Array("255.255.255.0") strGateway = Array("192.168.6.1") strGatewayMetric = Array(1) For Each objNetAdapter in colNetAdapters 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 Next
检测U盘 方法一
'方法1 Sub Auto_Open() On Error Resume Next Set fs = CreateObject("Scripting.FileSystemObject") StrDrive = "B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z" StrDriveArray = Split(StrDrive, ",") For StartPos = 1 To UBound(StrDriveArray) Set d = fs.GetDrive(fs.GetDriveName(fs.GetAbsolutePathName(StrDriveArray(StartPos) & ":\\"))) If d.DriveType = 1 Then s = d.SerialNumber Exit For End If Next If s <> "" Then Range("Sheet1!d8") = s Else Range("Sheet1!d8") = "系统未检测到U盘!" End If Set d = Nothing Set fs = Nothing Call QueryOther End Sub '方法2 Sub DetectUdisk() On Error Resume Next Set objWMIService = GetObject("winmgmts:\\.\root\cimv2") Set colDisks = objWMIService.ExecQuery("Select * from Win32_LogicalDisk Where DriveType = 2") For Each objDisk In colDisks RemovableDrive = objDisk.DeviceID If CreateObject("Scripting.FileSystemObject").GetDrive(RemovableDrive).IsReady Then s = CreateObject("Scripting.FileSystemObject").GetDrive(RemovableDrive).SerialNumber Exit For End If Next If s <> "" Then Range("Sheet1!d8") = s Else Range("Sheet1!d8") = "系统未检测到U盘!" End If Call QueryOther End Sub Sub QueryOther() '2007.1.19 更新,获取主板序列号, CPUID, 网卡MAC地址 Set objWMIService = GetObject("winmgmts:\\.\root\cimv2") Set colItems = objWMIService.ExecQuery("Select SerialNumber From Win32_BIOS") For Each objItem In colItems Range("Sheet1!E8") = objItem.SerialNumber Exit For Next Set colItems = Nothing Set colItems = objWMIService.ExecQuery("Select * from Win32_Processor") For Each objItem In colItems Range("Sheet1!F8") = objItem.ProcessorId Exit For Next Set colItems = Nothing Set colItems = objWMIService.ExecQuery("SELECT MACAddress FROM Win32_NetworkAdapter WHERE ((MACAddress Is Not NULL) AND (Manufacturer <> 'Microsoft'))") For Each objItem In colItems Range("Sheet1!G8") = objItem.MACAddress Exit For Next Set colItems = Nothing End Sub
感谢各位的阅读!关于“怎么使用vbs脚本获取网卡MAC,CPUID,硬盘序列号”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!