#30616 - 2002-10-13 09:50 PM
total memory on NT 4
|
Jtel
Fresh Scripter
Registered: 2002-04-13
Posts: 41
|
I have a script that is in place that detects, among other things, the amount of total physical memory. I have a mixed environment but the script works great except for detecting the memory on a handful of NT 4 machines. Here's the code that I have been using for NT 4:
code:
Shell "%comspec% /c winmsd /s /f" Shell '%comspec% /c type '+@wksta.txt+' | find " Total:" >$memtmp' If Open(1,$memtmp) = 0 $result = Trim(ReadLine(1)) $pos = InStr($result, "total:") If ($pos <> 0) $memory = SubStr($result,$pos+6,Len($result)-$pos-1) $memory = Val(Replace($memory,",","")) $memMB = $memory/1024 Else $memMB = "Unknown" EndIf $cf= Close(1) Del $memtmp EndIf
Obviously, the variables shown above along with the replace function are defined at the begining of the script. This code has been ran against 900 workstations and has only failed on 12 workstations. The workstations are in another state so I can't sit down at one of them to troubleshoot. The reason that this code is failing is because on these machines (for some reason that I can't explain) when the WINMSD summary report is created there is no memory information at all in the report.
Has anyone seen this before, or does anyone have any other suggestions for determining the memory on a NT 4 machine without using a 3rd party utility?
BTW... MemorySize(0) fails as well.
|
|
Top
|
|
|
|
#30617 - 2002-10-13 10:06 PM
Re: total memory on NT 4
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Does MemorySize() from KiXtart 4.10 or higher return the amount of memory?
|
|
Top
|
|
|
|
#30619 - 2002-10-14 12:06 AM
Re: total memory on NT 4
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11628
Loc: CA
|
Using WMI, here is an example:
code:
Break On ? "Workstation name is: " +@wksta ? "System Memory is: "val(WMIQuery("TotalPhysicalMemory","Win32_LogicalMemoryConfiguration"))/1024 " MB" ? "CPU Speed is: "WMIQuery("CurrentClockSpeed","Win32_Processor") " Mhz" ? "Operating system is: " @PRODUCTTYPE ? "System Manufacturer is: "WMIQuery("Manufacturer","Win32_ComputerSystem") ? "Logged on user is: " @USERID ? "Logon date is: " @DATE ? "Logon time is: " @TIME
FUNCTION WMIQuery($what,$where,) dim $strQuery, $objEnumerator, $value $strQuery = "Select $what From $where" $SystemSet = GetObject("winmgmts:{impersonationLevel=impersonate}!//@WKSTA") $objEnumerator = $SystemSet.ExecQuery($strQuery) For Each $objInstance in $objEnumerator If @Error = 0 and $objInstance <> "" $=execute("$$value = $$objInstance.$what") $WMIQuery="$value"+"|"+"$WMIQuery" EndIf Next $WMIQuery=left($WMIQuery,len($WMIQuery)-1) exit @error ENDFUNCTION
|
|
Top
|
|
|
|
#30620 - 2002-10-14 12:21 AM
Re: total memory on NT 4
|
Jtel
Fresh Scripter
Registered: 2002-04-13
Posts: 41
|
No, MemorySize() does not work. I am using KIX v 4.11. The machines do not have WMI installed. Most of the users would not have permissions to install it. I know that it could be done - but know if it would be worth it for just a few machines. I just thought maybe someone had another trick up their sleeve. I'd like to know why the WINMSD is not reporting any memory information.
|
|
Top
|
|
|
|
#30623 - 2002-10-14 03:42 AM
Re: total memory on NT 4
|
Jtel
Fresh Scripter
Registered: 2002-04-13
Posts: 41
|
The WMI example listed above works fine once WMI is installed. Unfortunately I am not familiar at all with WMI. Can anyone show me how to get the default gateway using WMI?
|
|
Top
|
|
|
|
#30625 - 2002-10-14 03:47 AM
Re: total memory on NT 4
|
Jtel
Fresh Scripter
Registered: 2002-04-13
Posts: 41
|
Lonkero, The machines with the problem are SP4. I have serveral SP4 machines for testing and they all return the desired information using the code I provided originally -- without using WMI. ??
|
|
Top
|
|
|
|
#30626 - 2002-10-14 06:23 AM
Re: total memory on NT 4
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
jtel,
From the NT Batch Newsgroup - Rob van der Woude:
quote:
Hi,
If you have access to PSTAT (part of the NT Resource Kit) try this (1 single command line):
for /f "tokens=2 delims=K " %%a in ('pstat ^| find "Memory:"') do set /a %%a / 1024
It may display 1MB less than the actual amount of memory, due to incorrect rounding down. Good luck,
Rob van der Woude
Alternatively, since you are running NT with an older Service Pack, you may want to run the following utility -
PsInfo
HTH,
Kent
|
|
Top
|
|
|
|
#30627 - 2002-12-05 03:07 PM
Re: total memory on NT 4
|
MCA
KiX Supporter
   
Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
|
Dear,
For another way of doing it on a system without WMI see our script memory.zip, which you can find on our site. The related topic is Read Workstation Memory thru Registry greetings.
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 533 anonymous users online.
|
|
|