Page 1 of 1

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

Posted: 12 Dec 2021 07:23
by MauricioDeAbreu
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.

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

Posted: 12 Dec 2021 12:40
by Compo
Could you use something like this?

Code: Select all

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

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

Posted: 12 Dec 2021 13:44
by MauricioDeAbreu
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.

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

Posted: 12 Dec 2021 16:47
by Squashman
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.

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

Posted: 13 Dec 2021 08:45
by MauricioDeAbreu
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.

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

Posted: 13 Dec 2021 09:35
by Squashman
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.

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

Posted: 13 Dec 2021 09:53
by MauricioDeAbreu
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.

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

Posted: 13 Dec 2021 11:04
by Squashman

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%

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

Posted: 13 Dec 2021 12:02
by MauricioDeAbreu
I am very grateful for the help Squashman has given me.

I couldn't have done it without you.

Resolved issue

Thanks...

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

Posted: 24 Jan 2022 07:29
by MauricioDeAbreu
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?

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

Posted: 24 Jan 2022 08:50
by ShadowThief
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

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

Posted: 25 Jan 2022 06:27
by MauricioDeAbreu
Thank you very much for the link, problem solved.