Dim oScalaPlayer,objWMIService,colItems
Set oScalaPlayer = CreateObject("ScalaPlayer.ScalaPlayer.1")
'获取本机IP和MAC
Function GetIPMAC(ComputerName)
Dim objItem,objAddress
Set objWMIService = GetObject("winmgmts://" & ComputerName & "/root/cimv2")
Set colItems = objWMIService.ExecQuery("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
For Each objItem in colItems
For Each objAddress in objItem.IPAddress
If objAddress <> "" then
GetIPMAC ="IP: " & objAddress & vbCrLf & "MAC: " & objItem.MACAddress & vbCrLf & "电脑名称:" & CreateObject("wscript.network").computername & vbCrLf
Exit For
End If
Next
Exit For
Next
End Function
'CPU占用情况
Function GetCPU(ComputerName)
Dim objSWbemObjectSet,SWbemObjectSet
Set objWMIService = GetObject("winmgmts://" & ComputerName & "/root/cimv2")
Set colItems = objWMIService.ExecQuery("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
Set objSWbemObjectSet = objWMIService.InstancesOf("Win32_Processor")
For Each SWbemObjectSet In objSWbemObjectSet
GetCPU = "CPU: " & SWbemObjectSet.Name & "[" & SWbemObjectSet.CurrentClockSpeed & "Hz]" & vbCrLf & _
" CPU使用率: " & SWbemObjectSet.LoadPercentage & "%"
Next
End Function
'获取CPU使用率
Function GetCPU2()
Set objProc = GetObject("winmgmts:\\.\root\cimv2:win32_processor='cpu0'")
Dim cpunum
cpunum = objProc.LoadPercentage
'MsgBox(TypeName(objProc.LoadPercentage))
'MsgBox(cpunum)
If Int(cpunum) <=0 Or cpunum="0" Or cpunum=" " Or cpunum=Null Then
cpunum= "0"
End If
GetCPU2 = "CPU使用率: " & cpunum & "%" & vbCrLf
End Function
'MsgBox "CPU 使用率: " & objProc.LoadPercentage & "%"
Set fsoobj = CreateObject("Scripting.FileSystemObject")
DriversInfo = GetDriversInfo
DriversInfo = Replace(DriversInfo, "|", vbCrLf)
sReturn = vbCrLf & "硬盘信息:" & vbCrLf & DriversInfo
'MsgBox sReturn
'获取硬盘占用情况
Function GetDriversInfo()
GetDriversInfo = ""
Set drvObj = fsoobj.Drives
For Each D In drvObj
Err.Clear
If D.DriveLetter <> "A" Then
If D.isReady Then
GetDriversInfo = GetDriversInfo & "分区: " & D.DriveLetter & vbCrLf
GetDriversInfo = GetDriversInfo & "可用空间: " & cSize(D.FreeSpace) & vbCrLf
GetDriversInfo = GetDriversInfo & "总大小: " & cSize( D.TotalSize) & vbCrLf
GetDriversInfo = GetDriversInfo & "使用率: " & (100*((D.TotalSize-D.FreeSpace)/D.TotalSize)) &"%"& vbCrLf
Else
End If
Else
End If
Next
End Function
'获取硬盘占用情况
Function cSize(tSize)
If tSize >= 1073741824 Then
cSize = Int((tSize / 1073741824) * 1000) / 1000 & "GB"
ElseIf tSize >= 1048576 Then
cSize = Int((tSize / 1048576) * 1000) / 1000 & "MB"
ElseIf tSize >= 1024 Then
cSize = Int((tSize / 1024) * 1000) / 1000 & "KB"
Else
cSize = tSize & "B"
End If
End Function
Function getInFo
Dim objWMIService,colItems,objItem,objAddress
Set bjWMIService = GetObject("winmgmts:\\" & "." & "\root\cimv2")
Set colItems =bjWMIService.ExecQuery("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
For Each objItem in colItems
For Each objAddress in objItem.IPAddress
If objAddress <> "" then
IP = objAddress 'IP地址
mac =objItem.MACAddress 'MAC地址
DHCPEnabled=objItem.DHCPEnabled '是否启用DHCP
DefaultIPGateway=objItem.DefaultIPGateway(0) '网关
IPSubnet=objItem.IPSubnet(0) '子网掩码
DNSServerSearchOrder1=objItem.DNSServerSearchOrder(0) 'DNS设置1
'DNSServerSearchOrder2=objItem.DNSServerSearchOrder(1) 'DNS设置2
Exit For
End If
Next
Exit For
Next
getInFo = getInFo & "电脑名称:" & CreateObject("wscript.network").computername & vbCrLf
getInFo = getInFo & "IP地址: " & ip & vbCrLf
getInFo = getInFo & "MAC地址:" & mac & vbCrLf
getInFo = getInFo & "网关: " & DefaultIPGateway & vbCrLf
getInFo = getInFo & "子网掩码: " & IPSubnet & vbCrLf
getInFo = getInFo & "DNS1: " & DNSServerSearchOrder1 & vbCrLf
End Function
Function getMemory
strComputer = "."
set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
set colOS = objWMI.InstancesOf("Win32_OperatingSystem")
for each objOS in colOS
strReturn = "内存总数: " & round(objOS.TotalVisibleMemorySize / 1024) & "MB" & vbCrLf &"内存可用数: " & round(objOS.FreePhysicalMemory / 1024) & "MB" & vbCrLf &"内存使用率 :" & Round(((objOS.TotalVisibleMemorySize-objOS.FreePhysicalMemory)/objOS.TotalVisibleMemorySize)*100) & "%"
'MsgBox strReturn
getMemory = strReturn
Next
End Function
Dim ws,i,mac,mem
set ws=createobject("wscript.shell")
i=0
Do While 1 'i<3
i=i+1
mac=GetCPU2()
mem=getMemory
scaCrawl = getInFo & GetCPU2() & getMemory & sReturn
'MsgBox scaCrawl
oScalaPlayer.sleep(1000)
loop