主頁 > 知識庫 > 用vbs腳本獲取網(wǎng)卡MAC,CPUID,硬盤序列號的實(shí)現(xiàn)代碼

用vbs腳本獲取網(wǎng)卡MAC,CPUID,硬盤序列號的實(shí)現(xiàn)代碼

熱門標(biāo)簽:福建ai電銷機(jī)器人加盟公司 熱血傳奇沃瑪森林地圖標(biāo)注 無錫電銷機(jī)器人銷售 招聘信息 揭陽外呼系統(tǒng)公司 去哪里辦卡 南召400電話辦理資費(fèi) 地圖標(biāo)注審核工作怎么樣注冊 鄭州中國移動(dòng)400電話申請 地圖標(biāo)注植物名稱

這里先給大家分享一個(gè)分配靜態(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

好了,這里就先介紹到這,需要的朋友可以參考一下。

標(biāo)簽:桂林 黔南 鹽城 景德鎮(zhèn) 文山 東莞 宣城 南昌

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《用vbs腳本獲取網(wǎng)卡MAC,CPUID,硬盤序列號的實(shí)現(xiàn)代碼》,本文關(guān)鍵詞  用,vbs,腳本,獲取,網(wǎng)卡,MAC,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《用vbs腳本獲取網(wǎng)卡MAC,CPUID,硬盤序列號的實(shí)現(xiàn)代碼》相關(guān)的同類信息!
  • 本頁收集關(guān)于用vbs腳本獲取網(wǎng)卡MAC,CPUID,硬盤序列號的實(shí)現(xiàn)代碼的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章