vbs脚本

Resource Page Description
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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值