This script allows you to pull the basic information of a remote device by IP address or Hostname. It must be ran as an administrator account.
It uses .vbs and WMI to perform the query.
Information returned includes:
-Model and Serial numbers
-BIOS Version
-Memory size
-Hard drive size
-MAC Address
-Monitor type
-Any local printers
-Timezone
-Currently logged in user (if any)
代码如下:
'This script will ask for a device name and then find out the basic computer information and display it in a dialog box
'This must be ran as an administrator
'Hitting cancel will display the information for the PC it was ran on
Dim objs
Dim obj
Dim WMI
Dim sAns
Dim Computer
strComputer = InputBox("Enter Full Device Name", "Getting your Infos")
'-------------------------------------------------------------------
Set WMI = GetObject("WinMgmts:\\" & strComputer)
Set objs = WMI.InstancesOf("Win32_Computersystem")
for Each obj In objs
model = obj.Model
memory = obj.totalphysicalmemory
USER = obj.UserName
Next
if memory > 1024 then
memory=memory/1024
memoryunit="KB"
end if
if memory > 1024 then
memory=memory/1024
memoryunit="MB"
end if
'if memory > 1024 then
' memory=memory/1024
' memoryunit="GB"
'end if
Set objs = WMI.InstancesOf("Win32_TimeZone")
for Each obj In objs
TZ = obj.StandardName
Next
Set objs = WMI.InstancesOf("Win32_BIOS")
for Each obj In objs
MBSerialNumber = obj.SerialNumber
BIOSVERSION = obj.SMBIOSBIOSVersion
Next
Set objs = WMI.InstancesOf("Win32_NetworkAdapterConfiguration")
for Each obj In objs
if obj.MACAddress<>"" then MACADDR = obj.MACAddress
Next
Set objs = WMI.InstancesOf("Win32_DiskDrive")
for Each obj In objs
HDDSize = obj.Size
Next
if HDDSize > 1024 then
HDDSize=HDDSize/1024
HDDSizeunit="KB"
end if
if HDDSize > 1024 then
HDDSize=HDDSize/1024
HDDSizeunit="MB"
end if
if HDDSize > 1024 then
HDDSize=HDDSize/1024
HDDSizeunit="GB"
end if
Set objs = WMI.InstancesOf("Win32_PnPEntity")
for Each obj In objs
if (obj.classguid = "{4D36E96E-E325-11CE-BFC1-08002BE10318}") then Monitor = mid(obj.DeviceID,9,instr(mid(obj.DeviceID,9),"\")-1)
if (left(obj.DeviceID,7) = "LPTENUM" AND obj.Description<>"Printer Port Logical Interface") then Printer = obj.Name
Next
wscript.echo strComputer & vbcrlf & vbcrlf & _
"Model = " & model & vbcrlf & _
"Serial = " & MBSerialNumber & vbcrlf & _
"Bios Version = " & BIOSVERSION & vbcrlf & _
"Memory = " & formatnumber(memory,0) & " " & memoryunit & vbcrlf & _
"HDD Size = " & formatnumber(HDDSize,0) & " " & HDDSizeunit & vbcrlf & _
"MAC Address = " & MACADDR & vbcrlf & _
"Monitor = " & Monitor & vbcrlf & _
"Printer = " & Printer & vbcrlf & _
"TimeZone = " & TZ & vbcrlf & _
"UserName = " & USER & vbcrlf