时间:2021-05-22
这里先给大家分享一个分配静态ip地址的代码
' Assign a Static IP AddressstrComputer = "."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 IfNext检测U盘 方法一
'方法1Sub 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 QueryOtherEnd Sub'方法2Sub 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 QueryOtherEnd SubSub 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好了,这里就先介绍到这,需要的朋友可以参考一下。
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
看了看别的资料有提取CPU,MAC的现成代码却没有硬盘序列号,找了好久才找到提取硬盘序列号的参数。于是自己给补上了。提取硬盘序列号functiondisk(){
硬盘序列号的查看方法: 一、硬盘序列号查询启用“硬盘序列号读取工具”软件,点“读取”软件窗口显示相应的硬盘序列号。如载AIDA64,然后打开存储设备-AT
机器码指的是将硬件序列号经过一系列加密、散列形成的一串序列号。硬盘,CPU都有一个无法修改的识别码。网卡的MAC其实也算一种,但它是可以人为修改的。 软件为了
代码如下:复制代码代码如下://获得网卡序列号publicstringGetMoAddress(){stringMoAddress="";ManagementC
电脑中的硬盘想要查看硬盘序列号,每块硬盘都会自己的唯一序列号,我们如果想要查看自己硬盘的序列号,该怎么查看呢?下面我们就来看看详细的教程。1、在Windows1