用vbs脚本获取网卡MAC,CPUID,硬盘序列号的实现代码
这里先给大家分享一个分配静态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
好了,这里就先介绍到这,需要的朋友可以参考一下。
上一篇:WINDOWS特有的消息常量标识符(vb,vbs常用)
栏 目:vb
下一篇:vbs 复制指定文件到指定目录下
本文标题:用vbs脚本获取网卡MAC,CPUID,硬盘序列号的实现代码
本文地址:https://www.xiuzhanwang.com/a1/vb/7089.html
您可能感兴趣的文章
- 01-10下载文件到本地运行的vbs
- 01-10VBS中的正则表达式的用法大全 <font color=red>原创&
- 01-10VBS中SendKeys的基本应用
- 01-10VBScript教程 第十一课深入VBScript
- 01-10用VBSCRIPT控制ONSUBMIT事件
- 01-10VBScript语法速查及实例说明
- 01-10VBS中Select CASE的其它用法
- 01-10VBScript教程 第七课使用条件语句
- 01-10vbscript 可以按引用传递参数吗?
- 01-10VBScript教程 第二课在HTML页面中添加VBscript代码
阅读排行
本栏相关
- 01-10下载文件到本地运行的vbs
- 01-10飘叶千夫指源代码,又称qq刷屏器
- 01-10SendKeys参考文档
- 01-10什么是一个高效的软件
- 01-10VBS中的正则表达式的用法大全 &l
- 01-10exe2swf 工具(Adodb.Stream版)
- 01-10VBS中SendKeys的基本应用
- 01-10用VBSCRIPT控制ONSUBMIT事件
- 01-10VBScript教程 第十一课深入VBScript
- 01-10VBScript语法速查及实例说明
随机阅读
- 08-05DEDE织梦data目录下的sessions文件夹有什
- 01-10SublimeText编译C开发环境设置
- 08-05dedecms(织梦)副栏目数量限制代码修改
- 01-10使用C语言求解扑克牌的顺子及n个骰子
- 01-11Mac OSX 打开原生自带读写NTFS功能(图文
- 04-02jquery与jsp,用jquery
- 01-10C#中split用法实例总结
- 08-05织梦dedecms什么时候用栏目交叉功能?
- 01-11ajax实现页面的局部加载
- 01-10delphi制作wav文件的方法