Page 1 of 1 1
Topic Options
#30616 - 2002-10-13 09:50 PM total memory on NT 4
Jtel Offline
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 Offline
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?
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#30618 - 2002-10-13 10:18 PM Re: total memory on NT 4
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11628
Loc: CA
If MemorySize() does not work, what about simply using a WMI solution? or do these NT 4 machines not have WMI installed? Can you install WMI... You can then report on just about anything you want. Microsoft SMS installs WMI to get some of its reporting capabilities as well.
Top
#30619 - 2002-10-14 12:06 AM Re: total memory on NT 4
NTDOC Administrator Offline
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 Offline
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
#30621 - 2002-10-14 02:11 AM Re: total memory on NT 4
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
eh, just wild quess, there is sp <4 or even <3

but, probably you have already checked that...
_________________________
!

download KiXnet

Top
#30622 - 2002-10-14 02:32 AM Re: total memory on NT 4
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
I would also recommend to install SP6a (if not present) and also WMI. It'll make it easier to retrieve all kinds of hardware info. Additionally, there have already been a couple of scripts posted that remotely deploy WMI, thus you don't have to worry about end user permissions. And for 12 machines it could also be done manually by just scheduling a Task Scheduler task that silently installs WMI.

[ 14. October 2002, 02:32: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#30623 - 2002-10-14 03:42 AM Re: total memory on NT 4
Jtel Offline
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
#30624 - 2002-10-14 03:44 AM Re: total memory on NT 4
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
jtel, so did you get any info on the problem you had first?
 
_________________________
!

download KiXnet

Top
#30625 - 2002-10-14 03:47 AM Re: total memory on NT 4
Jtel Offline
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 Offline
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
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#30627 - 2002-12-05 03:07 PM Re: total memory on NT 4
MCA Offline
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.
_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 533 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.148 seconds in which 0.075 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org