Memory size per slot / Tamaño de memoria por ranura

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
MauricioDeAbreu
Posts: 40
Joined: 12 Dec 2021 06:45

Memory size per slot / Tamaño de memoria por ranura

#1 Post by MauricioDeAbreu » 12 Dec 2021 07:23

Hi, I'm new to batch code stuff.

And I am preparing a Batch that checks the memory and the hard disk of the laptops that I must audit

But I ran into a problem, and it is that I need to know the memory size per slot.

Since for example, it could have a total of 4 GB of RAM (the correct thing), but distributed in two modules of 2 GB (the incorrect thing), which would be incorrect within the revision parameters.

The question is, what command could be used to obtain this information.

In advance I thank you for the help, and I apologize for my English, I used a translator.

Compo
Posts: 599
Joined: 21 Mar 2014 08:50

Re: Memory size per slot / Tamaño de memoria por ranura

#2 Post by Compo » 12 Dec 2021 12:40

Could you use something like this?

Code: Select all

%SystemRoot%\System32\wbem\WMIC.exe MemoryChip Get BankLabel, Capacity

MauricioDeAbreu
Posts: 40
Joined: 12 Dec 2021 06:45

Re: Memory size per slot / Tamaño de memoria por ranura

#3 Post by MauricioDeAbreu » 12 Dec 2021 13:44

Hello, thanks for answering.

I think I understand that the command would give me the size of the memory and the slot it is in.

But, I think there would be no way to implement it to fix my problem.

I will try to explain myself better.

The laptops leave the warehouse with 4GB of RAM in a single memory module. But, sometimes, when they arrive from the street, they arrive with 2 modules of 2GB, which is a real problem, since this leads to reports, meetings, etc.

One of the things the Batch you create does is visually alert (image) to basic changes in memory.
Example:
1- Alert when the memory size is less than 4GB
2- Alert that everything is OK, when the memory size is 4GB
3- Alert when the memory size is 6GB
4- Alert when the memory size is 8GB

As you can see, the alerts will work fine in all circumstances, except when they remove the 4GB module, to replace it with 2 of 2GB.
So my code would say that they have not replaced the 4GB module, since, when using the memory size to give the alert, this value will be 4GB (2GB + 2GB) and it will say that the equipment is OK, which is false, since they have changed the module for 2 of 2GB.

So I was wondering, if there was a way to know the size of the memory per slot, so, I suppose, I could determine that despite having put 2 2GB modules, a change has been made and give a relevant alert.

To give you an idea, something like: wmic MEMORYCHIP get bank1, capacity

The idea is to assign the memory size of each slot to a variable, and with that variable carry out the necessary checks to give the pertinent alerts.

Is this possible, and how can it be done?

Thanks in advance for the help you can give me.

Squashman
Expert
Posts: 4465
Joined: 23 Dec 2011 13:59

Re: Memory size per slot / Tamaño de memoria por ranura

#4 Post by Squashman » 12 Dec 2021 16:47

I am not sure I am following what you are talking about. The code will show the capacity of each stick of ram installed in the computer. If there is 2 sticks installed it will show two lines of output. Feel free to add devicelocator to that WMIC command.

MauricioDeAbreu
Posts: 40
Joined: 12 Dec 2021 06:45

Re: Memory size per slot / Tamaño de memoria por ranura

#5 Post by MauricioDeAbreu » 13 Dec 2021 08:45

It certainly shows the amount of memory per slot.

But, the problem is that the alerts are visual, I mean, when there is a discrepancy between the components, an image is opened in full screen, with the sole purpose of preventing the error from being overlooked.

That is, there is an image for each type of error, which, when opened, remains as a wallpaper, which is in the foreground, blocking, as it were, the entire desktop.

That is why I am looking for a way to extract the content of each slot, to be able to handle it in a variable and thus be able to carry out the alert.

The idea is to add the memory size of one slot to variable A, and the memory size of the other slot to variable B

I don't know if I can make myself understood.

Squashman
Expert
Posts: 4465
Joined: 23 Dec 2011 13:59

Re: Memory size per slot / Tamaño de memoria por ranura

#6 Post by Squashman » 13 Dec 2021 09:35

So you want that output assigned to a variable. That is easy. But what else are going to continue to ask for. We are not going to sit here for a few days and weeks and keep providing answer to your code request if you are not going to make any effort yourself to even attempt to do it yourself.

MauricioDeAbreu
Posts: 40
Joined: 12 Dec 2021 06:45

Re: Memory size per slot / Tamaño de memoria por ranura

#7 Post by MauricioDeAbreu » 13 Dec 2021 09:53

First of all, I apologize for not being able to explain myself from the beginning, perhaps the language barrier played a role.

Regarding the subject, I just want that, assign to a variable each one of the memory sizes that are in each slot.

Example: A = Size Slot0 and B = Size Slot1

Thankful in advance, as I have no idea how to reference each one, despite having searched the net.

Squashman
Expert
Posts: 4465
Joined: 23 Dec 2011 13:59

Re: Memory size per slot / Tamaño de memoria por ranura

#8 Post by Squashman » 13 Dec 2021 11:04

Code: Select all

@ECHO OFF

SET "DIMM1="
SET "DIMM2="
for /F "tokens=2 skip=2 delims=," %%G IN (
	'"wmic memorychip get devicelocator,capacity /format:csv"'
) do (
	IF NOT DEFINED DIMM1 (
		set "DIMM1=%%G"
	) ELSE (
		IF NOT DEFINED DIMM2 SET "DIMM2=%%G"
	)
)
IF DEFINED DIMM1 echo DIMM1 Capacity: %DIMM1%
IF DEFINED DIMM2 echo DIMM2 Capacity: %DIMM2%

MauricioDeAbreu
Posts: 40
Joined: 12 Dec 2021 06:45

Re: Memory size per slot / Tamaño de memoria por ranura

#9 Post by MauricioDeAbreu » 13 Dec 2021 12:02

I am very grateful for the help Squashman has given me.

I couldn't have done it without you.

Resolved issue

Thanks...

MauricioDeAbreu
Posts: 40
Joined: 12 Dec 2021 06:45

Re: Memory size per slot / Tamaño de memoria por ranura

#10 Post by MauricioDeAbreu » 24 Jan 2022 07:29

I have a compatibility problem on Windows Seven.

When I run this code, it gives me the following message: Invalid XSL format (or) file name.

I guess it's because of the CSV format

Is there a way to overcome this incompatibility?

ShadowThief
Expert
Posts: 1160
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Memory size per slot / Tamaño de memoria por ranura

#11 Post by ShadowThief » 24 Jan 2022 08:50

MauricioDeAbreu wrote:
24 Jan 2022 07:29
I have a compatibility problem on Windows Seven.

When I run this code, it gives me the following message: Invalid XSL format (or) file name.

I guess it's because of the CSV format

Is there a way to overcome this incompatibility?
It's a known bug specific to Windows 7 (and Server 2008). https://stackoverflow.com/questions/967 ... n-windows7

MauricioDeAbreu
Posts: 40
Joined: 12 Dec 2021 06:45

Re: Memory size per slot / Tamaño de memoria por ranura

#12 Post by MauricioDeAbreu » 25 Jan 2022 06:27

Thank you very much for the link, problem solved.

Post Reply