Thu May 13, 2010 2:00 am
Ok I have two. They are just vbs files. I attached the files also. They use wmi instead of snmp so i cant figure out how to put them in the labels
This one just finds out who is logged on.
'WhoLogonInput.vbs
' Sample VBScript to discover which user is logged on
' Author Guy Thomas and John Eck
' Version 2.5 - December 2005
' -------------------------------------------------------'
Option Explicit
Dim objWMIService, objComputer, colComputer
Dim strLogonUser, strLogonUser1, strComputer
strComputer = "."
strComputer = wscript.arguments(0)
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colComputer = objWMIService.ExecQuery ("Select * from Win32_ComputerSystem")
For Each objComputer in colComputer
If not objComputer.UserName = "" Then
strLogonUser = Split(objComputer.UserName,"\")
strLogonUser(1) = UCase(Left(strLogonUser(1),1))& Trim(Mid(strLogonUser(1),2,20))
Wscript.Echo strLogonUser(1) & " is logged on at " & strComputer
Else
Wscript.Echo "No one is currently logged on at " & strComputer
End If
Next
' End of Sample Logged on VBScript
This one gives additional info
If WScript.Arguments.Count = 1 Then
strComputer = WScript.Arguments.Item(0)
Else
strComputer = InputBox("Enter Computer Name")
End If
'
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
'**********************Get Operating System *******************************************************************
Set colItems = objWMIService.ExecQuery( _
"SELECT * FROM Win32_OperatingSystem",,48)
For Each objItem in colItems
os = "-----------------------------------" & vbCrLf & "PrimaryOS: " & objItem.Caption & vbCrLf & "-----------------------------------"
Next
'**********************Get Cpu Info*******************************************************************
Set colItems = objWMIService.ExecQuery( _
"SELECT * FROM Win32_Processor",,48)
For Each objItem in colItems
if instr(os,"2000") < 1 then cores = objitem.NumberOfCores
cpu = "-----------------------------------" & vbCrLf & "CPU Name: " & objItem.Name & vbCrLf & "Cores = " & Cores & _
" Clock Speed = " & objitem.CurrentClockSpeed & vbCrLf & "-----------------------------------"
Next
'**********************Get Number and size of memory chips *******************************************************************
Set colItems = objWMIService.ExecQuery( _
"SELECT * FROM Win32_PhysicalMemory",,48)
For Each objItem in colItems
dimmnum = dimmnum +1
dimmsize= cdbl(objitem.capacity)
if dimmsize > 1000000000 then
mem= mem & "-----------------------------------" & vbCrLf & "Dimm"& dimmnum &" Size: " & FormatNumber(dimmsize / 1000000000,2) & " GB" & vbCrLf & "-----------------------------------"
Else
mem= mem & "-----------------------------------" & vbCrLf & "Dimm"& dimmnum &" Size: " & FormatNumber(dimmsize / 1000000,2) & " MB" & vbCrLf & "-----------------------------------"
End if
Next
'**********************Get Model, Hostname, Logged in User, Total Memory *******************************************************************
Set colItems = objWMIService.ExecQuery( _
"SELECT * FROM Win32_ComputerSystem",,48)
For Each objItem in colItems
model = "-----------------------------------" & vbCrLf & "Model: " & objItem.Model & vbCrLf & "-----------------------------------"
name = "-----------------------------------" & vbCrLf & "Hostname: " & objItem.name & vbCrLf & "-----------------------------------"
if ("-" & objitem.UserName & "-") = "--" then
username=" Nobody"
Else
username = objitem.UserName
end if
user = "-----------------------------------" & vbCrLf & "Logged In user:" & UserName & ":" & vbCrLf & "-----------------------------------"
dimmsize= cdbl(objitem.TotalPhysicalMemory)
if dimmsize > 1000000000 then
mem= mem & "-----------------------------------" & vbCrLf & "Total Memory: "& FormatNumber(dimmsize/1000000000,2) & " GB " & "(" & FormatNumber(dimmsize,0) & " Bytes)" & vbCrLf & "-----------------------------------"
Else
mem= mem & "-----------------------------------" & vbCrLf & "Total Memory:" & FormatNumber(dimmsize/10000,2) & " GB " & "(" & FormatNumber(dimmsize,0) & " Bytes)" & vbCrLf & "-----------------------------------"
End if
Next
'**********************Get Hard Drive Information *******************************************************************
Set colDisks = objWMIService.ExecQuery _
("Select * from Win32_LogicalDisk Where MediaType = '12'")
For Each objDisk in colDisks
drivespace = drivespace & "-----------------------------------" & vbCrLf & objdisk.deviceid & " " & int(objdisk.size/ 1000000000) & " GB total " & _
int(objDisk.FreeSpace/ 1000000000) & " GB free" & vbCrLf & "-----------------------------------"
Next
wscript.echo user & name & os & Model & totmem & mem & cpu & drivespace