溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

怎么使用vbs腳本獲取網(wǎng)卡MAC,CPUID,硬盤序列號

發(fā)布時間:2021-05-22 10:27:03 來源:億速云 閱讀:340 作者:小新 欄目:開發(fā)技術(shù)

這篇文章給大家分享的是有關(guān)怎么使用vbs腳本獲取網(wǎng)卡MAC,CPUID,硬盤序列號的內(nèi)容。小編覺得挺實用的,因此分享給大家做個參考,一起跟隨小編過來看看吧。

這里先給大家分享一個分配靜態(tài)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")?=?"系統(tǒng)未檢測到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")?=?"系統(tǒng)未檢測到U盤!"
???End?If
???Call?QueryOther
End?Sub
Sub?QueryOther()
???'2007.1.19?更新,獲取主板序列號,?CPUID,?網(wǎng)卡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

感謝各位的閱讀!關(guān)于“怎么使用vbs腳本獲取網(wǎng)卡MAC,CPUID,硬盤序列號”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,讓大家可以學(xué)到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI