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
USB 검사 방법 1

'  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
자,여기까지 소개 하 겠 습 니 다.필요 한 친 구 는 참고 하 세 요.

좋은 웹페이지 즐겨찾기