Author Topic: Display System Information  (Read 5835 times)

IRBME_

  • Guest
Display System Information
« on: October 11, 2003, 12:35:07 PM »
This is a system information script

that allows you to read various information about the hardware and the system and display them to the channel.

You

need WMI (Windows Management Instrumentation) installed. Most systems should already have this.

This system

information script is by far in no way complete. Instead it just acts as a template/example of how to create a more complete

script. You can add an incredible amount information about pretty much anything you like.

This script shows you how

to get some information about the following:Network Adapters, BIOS, KeyBoard, Mouse, CDRom drives, HardDisk drives.

A

complete list of the classes available for you to use is listed

here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_classes.asp

For help

installing the script, seek assistance at the support channels:

#icechat on US.RoIRC.Org
#icechat on

irc.quakenet.org

or read the help files.

Here it is:

Code: [Select]

Dim Adapter
Dim

BIOS
Dim KeyBoard
Dim Mouse
Dim CDRom
Dim DiskDrive
Dim item

Function Aliases (Command, Parameters,

ServerNumber)

Dim S

select case UCase(Command)

case

"/NETWORK"

Aliases = true



Dim i, j, found
Dim AdaptersUsed()

Set Adapter =

GetObject("winmgmts:").instancesOf("Win32_NetworkAdapter")
ReDim

AdaptersUsed(0)

SendCommand "/say " & channel & " 3Network

Interfaces:", ServerNumber

for each item in Adapter
if

item.AdapterType <> vbnullstring then
found = false



for j = 1 to ubound(AdaptersUsed)


if AdaptersUsed(j) = item.AdapterType then
found = true


exit for
end if


next

if not found then


ReDim Preserve AdaptersUsed(ubound(AdaptersUsed) + 1)


AdaptersUsed (ubound(AdaptersUsed)) = item.AdapterType

S =

"12Adapter Type: " & item.AdapterType & " 4| " & _


"12Description: " & item.Description & " 4| " & _


"12MACAddress: " & item.MACAddress & " 4| " & _


"12Manufacturer: " & item.Manufacturer & " 4|

" & _
"12Name: " & item.Name &

" 4| " & _
"12ProductName: " &

item.ProductName

SendCommand "/say " & channel

& " " & S, ServerNumber
i = i + 1


if i = 3 then exit for
end if
end

if
next

case "/BIOS"
Aliases = true


Set BIOS = GetObject("winmgmts:").instancesOf("Win32_BIOS")



SendCommand "/say " & channel & " 3BIOS:", ServerNumber



for each item in BIOS
S = "12Caption: " & item.Caption

& " 4| " & _
"12Description: " &

item.Description & " 4| " & _
"12Name: " &

item.Name & " 4| " & _
"12SerialNumber: " &

item.SerialNumber & " 4| " & _
"12SoftwareElementID:

" & item.SoftwareElementID & " 4| " & _


"12Status: " & item.Status & " 4| " & _


"12Version: " & item.Version



SendCommand "/say " & channel & " " & S, ServerNumber
next



case "/KEYBOARD"
Aliases = true


Set KeyBoard =

GetObject("winmgmts:").instancesOf("Win32_Keyboard")



SendCommand "/say " & channel & " 3Keyboard:", ServerNumber



for each item in KeyBoard
S = "12Caption: " & item.Caption &

" 4| " & _
"12Description: " & item.Description

& " 4| " & _
"12Name: " & item.Name



SendCommand "/say " & channel & "

" & S, ServerNumber
next

case "/MOUSE"


Aliases = true
Set Mouse =

GetObject("winmgmts:").instancesOf("Win32_PointingDevice")



SendCommand "/say " & channel & " 3Mouse:", ServerNumber



for each item in Mouse
S = "12Caption: " & item.Caption

& " 4| " & _
"12Description: " &

item.Description & " 4| " & _
"12HardwareType: "

& item.HardwareType & " 4| " & _
"12Manufacturer:

" & item.Manufacturer & " 4| " & _


"12NumberOfButtons: " & item.NumberOfButtons



SendCommand "/say " & channel & " " & S, ServerNumber


next

case "/CDROM"
Aliases = true
Set CDRom

= GetObject("winmgmts:").instancesOf("Win32_CDROMDrive")



SendCommand "/say " & channel & " 3CD ROM Drives:", ServerNumber



for each item in CDRom
S = "12Caption: " & item.Caption &

" 4| " & _
"12Description: " & item.Description

& " 4| " & _
"12Drive: " & item.Drive &

" 4| " & _
"12MediaType: " & item.MediaType &

" 4| " & _
"12Manufacturer: " & item.Manufacturer

& " 4| " & _
"12Name: " & item.Name &

" 4| " & _
"12Size: " & item.Size/1024/1024 &

"MB"

SendCommand "/say "

& channel & " " & S, ServerNumber
next

case

"/HDD"
Aliases = true
Set DiskDrive =

GetObject("winmgmts:").instancesOf("Win32_DiskDrive")



SendCommand "/say " & channel & " 3Hard Disk Drives:", ServerNumber



for each item in DiskDrive
S =  "12Caption: " & item.Caption & "

4| " & _
"12Description: " & item.Description & "

4| " & _
"12InterfaceType: " & item.InterfaceType &

" 4| " & _
"12Manufacturer: " & item.Manufacturer

& " 4| " & _
"12MediaType: " & item.MediaType

& " 4| " & _
"12MinBlockSize: " &

item.MinBlockSize & " 4| " & _
"12Model: " &

item.Model & " 4| " & _
"12Name: " & item.Name

& " 4| " & _
"12Partitions: " &

item.Partitions & " 4| " & _
"12SectorsPerTrack: "

& item.SectorsPerTrack & " 4| " & _
"12Size: "

& item.Size/1024/1024 & "MB"



SendCommand "/say " & channel & " " & S, ServerNumber
next


End Select

End Function



Usage:

/network  - Displays network card

information
/bios        - Displays information about the BIOS
/keyboard - Display keyboard information
/mouse     -

Display mouse information
/cdrom     - Display information about the CD Rom drives
/hdd         - Display information

about the hard disk drives


In order to add more information, in general you should first add a new decleration at

the top. For example, "Dim FloppyDrives".

Then you want to add a new alias at the end of the "Select Case" statement,

like:

Code: [Select]

case "/FLOPPY"
  Aliases = true


Make sure

it's in upper case! That's important!

Next you need to create the actual object like

this:

Code: [Select]


Set FloppyDrives =

GetObject("winmgmts:").instancesOf("Win32_FloppyDrive")




Now we need to loop through each drive:

Code: [Select]

for each item in

FloppyDrives


Inside the loop, you now display the information you want about this drive. The

properties and methods available are listed at the site above. For example, here is the URL for the floppy drive class:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_floppydrive.asp

Construct it like

this:

Code: [Select]

         S = "12Description: " & item.Description
       
     

   SendCommand "/say " & channel & " " & S, ServerNumber

Next 'Remember to close off

the loop


As a sample excercise, try to add the floppy drive description to the script by

following the steps above. If you manage that, examine the class at the link provided and see if you can add more information

like the Manufacturer (there's one I just gave away for you). Then go away and add info for other devices and post it

here!

That's it. If you manage to add any other cool things to this script - please by all means post any additional

code below! I'd like to see people adding to the script and making it grow. It's always expandable - always some other

piece of hardware info that could be added.

Please also post any comments and/or suggestions.

Thanks.

Efwis

  • Newbie
  • *
  • Posts: 10
    • http://
Re: Display System Information
« Reply #1 on: September 14, 2005, 08:58:34 AM »
ok, I have the script copied and saved. but i got a problem.

when I go to add the memory info into the script it doesn't show anything except  "Mem:"

here is the code that I have put together, why isn't it working, I have used different modules with the same results everytime.

Code: [Select]
case "/MEM"     
Aliases = true     
Set Ram = GetObject("winmgmts:").instancesOf("Win32_lMemoryArray")     

SendCommand "/say " & channel & " 3Mem:", ServerNumber     

for each item in lMemoryArray
S =  "12Caption: " & item.Caption & " 4| " & _     
"12Description: " & item.Description & " 4| " & _
"12Status: " & item.Status & " 4| " &_
"12BlockSize: " & item.BlockSize & "  4| " & _   
"12NumberOfBlocks: " & item.NumberOfBlocks & "  4| " & _   
"12Size: " & item.Size/1024/1024 & "MB"   

SendCommand "/say " & channel & " " & S, ServerNumber     
next     
any help in fixing this would be great.

also I am trying to set up an alias that would post all the information out with one command, rather then have a seperate command for each, and ideas on setting that up?
« Last Edit: September 14, 2005, 09:01:04 AM by Efwis »

Snerf

  • Administrator
  • Hero Member
  • *****
  • Posts: 1787
    • IceChat IRC Client
Re: Display System Information
« Reply #2 on: September 14, 2005, 11:11:50 AM »
Would it not be "For each item in Ram" , since your using:

Set Ram = GetObject("winmgmts:").instancesOf("Win32_lMemoryArray") 

Of course, I have no idea if the rest of it would work, I just noticed that 1 mistake.

If you want to do it all with one command, make an alias that runs them all.
Aliases can contain multiple commands, each on a seperate line.
« Last Edit: September 14, 2005, 11:18:07 AM by Snerf »
The IceChat God