mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jan 2005
Posts: 41
S
swgiant Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Jan 2005
Posts: 41
I duuno how to vb, so i would like to ask can someone guide me on the snippet of codes to retrieve the processor model, speed then ram? sample as follow, which taken from vista properties...

Processor: Intel(R) Pentium(R) M processor 1.70GHz
Memory (RAM): 1.99 GB

million thanks...

Joined: Dec 2002
Posts: 3,138
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,138
There are snippets and DLLs that will do this on mircscripts.org and mirc.net, most notably moo script, which uses COM Objects to get the information from WMI (Windows Management Instrumentation).

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Here's one for checking the processor:
Code:
procinfo {
  ; $1 can include these and more: Caption,Manufacturer,MaxClockSpeed,Name,NumberOfCores,ProcessorType,Version
  var %a = a $+ $ticks, %b = b $+ $ticks
  .comopen %a WBemScripting.SWBemLocator
  if (!$com(%a)) { 
    echo -abcfilqrt info * /procinfo: problem connecting to WMI. 
    return
  }
  .comclose %a $com(%a,ConnectServer,1,dispatch* %b)
  if (!$com(%b)) { 
    echo -abcfilqrt info * /procinfo: problem connecting to WMI. 
    return
  }
  var %query = SELECT $1 FROM Win32_Processor
  .comclose %b $com(%b,ExecQuery,1,bstr,%query,dispatch* %a)
  if (!$com(%a)) { 
    echo -abcfilqrt info * /procinfo: problem connecting to WMI. 
    return
  }
  var %i = 1, %n = $comval(%a,0)
  while (%i <= %n) {
    var %value = $comval(%a,%i,$1)
    if (%i < %n) { linesep -a }
    inc %i
  }
  .comclose %a
  return %value
}


Use: //echo -a $procinfo(Name)

As noted, you can get other information from it by replacing "Name" with one of the other values lised at the top of the script. ($1 is the text inside the parentheses).

And here is one for memory:
Code:
memory {
  ; $1 can include these: AvailableVirtualMemory,Caption,Description,Name,SettingID,TotalPageFileSpace,TotalPhysicalMemory,TotalVirtualMemory
  .comopen xpver1 WbemScripting.SWbemLocator
  .comclose xpver1 $com(xpver1,ConnectServer,1,dispatch* xpver2)
  if $com(xpver2) {
    .comclose xpver2 $com(xpver2,ExecQuery,1,bstr*,select $1 from Win32_LogicalMemoryConfiguration,dispatch* xpver3)
    if $com(xpver3) {
      var %a = $comval(xpver3,1,$1)
      .comclose xpver3
      return $bytes($calc(%a * 1024)).suf
    }
  }
}


Use: //echo -a $memory(TotalPhysicalMemory)

Again, you can replace the text inside the parentheses with any of the items listed in the comment at the top.


Invision Support
#Invision on irc.irchighway.net
Joined: Jan 2005
Posts: 41
S
swgiant Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Jan 2005
Posts: 41
thanks to all of you. I got the codes what i need. grin

Joined: Jan 2005
Posts: 41
S
swgiant Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Jan 2005
Posts: 41
//echo -a $memory(TotalPhysicalMemory)

returns 0B

I tried other parameter but also return 0B. can fix it for me?

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
What operating system do you have? That one is supported with Windows 2003 and it does work in XP for me, though it says it's no longer supported. I'm assuming Vista would fail with that one.

Try this one instead. It works for Windows Server 2003, Windows XP, Windows 2000, and Windows NT 4.0. I believe it will also work for Vista, but I can't verify that here.
Code:
memory {
  ; $1 can include these: FreePhysicalMemory,FreeSpaceInPagingFiles,FreeVirtualMemory,TotalSwapSpaceSize,TotalVirtualMemorySize,TotalVisibleMemorySize.
  ;It can include other items, but the result won't be right because it uses $bytes/$calc to make the output in MB/GB and other OS stuff won't look right that way.
  .comopen xpver1 WbemScripting.SWbemLocator
  .comclose xpver1 $com(xpver1,ConnectServer,1,dispatch* xpver2)
  if $com(xpver2) {
    .comclose xpver2 $com(xpver2,ExecQuery,1,bstr*,select $1 from Win32_OperatingSystem,dispatch* xpver3)
    if $com(xpver3) {
      var %a = $comval(xpver3,1,$1)
      .comclose xpver3
      return $bytes($calc(%a * 1024)).suf
    }
  }
}


Use: //echo -a $memory(TotalVisibleMemorySize)

That will show the total physical memory. You can use any of the other items listed in the first line.


Invision Support
#Invision on irc.irchighway.net
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Here's a slightly more detailed one that will tell you how much memory is installed in each memory location.

Code:
memory {
  echo -a Physical Memory:
  var %cnt = 1, %totalmemory = $memory2(0)
  while (%cnt <= %totalmemory) {
    echo -a $memory2(%cnt)
    inc %cnt
  }
  echo -a Total: $bytes(%capacity.total).suf
  unset %capacity.total
}
memory2 {
  .comopen xpver1 WbemScripting.SWbemLocator
  .comclose xpver1 $com(xpver1,ConnectServer,1,dispatch* xpver2)
  if $com(xpver2) {
    .comclose xpver2 $com(xpver2,ExecQuery,1,bstr*,select * from Win32_PhysicalMemory,dispatch* xpver3)
    if $com(xpver3) {
      if ($1 == 0) { var %total = $comval(xpver3,0) | .comclose xpver3 | return %total }
      var %location = $comval(xpver3,$1,DeviceLocator)
      var %capacity = $comval(xpver3,$1,Capacity)
      inc %capacity.total %capacity
      var %capacity.suf = $bytes(%capacity).suf
      var %formfactor.values = Unknown Other SIP DIP ZIP SOJ Proprietary SIMM DIMM TSOP PGA RIMM SODIMM SRIMM SMD SSMP QFP TQFP SOIC LCC PLCC BGA FPBGA LGA
      var %formfactor = $gettok(%formfactor.values,$calc($comval(xpver3,$1,FormFactor) + 1),32)
      .comclose xpver3
      return  $+ %location $+ : %capacity.suf %formfactor
    }
  }
}


Use: /memory

Example Output:
Physical Memory:
DDR1: 256MB DIMM
DDR2: 512MB DIMM
DDR3: 256MB DIMM
Total: 1GB

You can use this one, or the previous one depending on what you're looking for. Note that if you want this one to display the output to others, you'll need to change all 3 "echo -a" to "say".

Last edited by Riamus2; 11/09/07 05:47 PM.

Invision Support
#Invision on irc.irchighway.net
Joined: Jan 2005
Posts: 41
S
swgiant Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Jan 2005
Posts: 41
really thanks to Riamus2. now your codes all working now.. thank you much...

Joined: Apr 2003
Posts: 342
M
Fjord artisan
Offline
Fjord artisan
M
Joined: Apr 2003
Posts: 342
Hmmm... Maybe I'll debug this later... but I tried your code and got this...

Code:
Physical Memory:
DIMM 1: 512MB Unknown
DIMM 2: 512MB Unknown
DIMM 1: 512MB Unknown
DIMM 2: 512MB Unknown
DIMM 3: 1GB Unknown
DIMM 4: 1GB Unknown
Total: 4GB


The total is correct, and there are six DIMMs installed. But it only goes up to 4.

I doubt you can correct this but if I find the problem I'll let you know. smile


Beware of MeStinkBAD! He knows more than he actually does!
Joined: Dec 2002
Posts: 503
B
Fjord artisan
Offline
Fjord artisan
B
Joined: Dec 2002
Posts: 503
Umm, there's 6 lines there. 4 x 512MB + 2 x 1GB.

As to why it says DIMM 1 & DIMM 2 twice, well, that's a different question that stems from the 'Win32_PhysicalMemory' query..


Link Copied to Clipboard