Computer Hope
Microsoft => Microsoft DOS => Topic started by: jdogherman on March 27, 2008, 02:26:53 PM
-
Does anyone know of a way to check for the total installed ram in a batch file.
I need to make a check for total installed memory before running a command.
I know about the mem command but I really dont know how to parse the output and then compair to another string.
Thank you,
Justin
-
try somethink like this:
wmic memorychip get /VALUE |findstr "Capacity"
and notice that the Capacity is in kb
-
when I do that it it states:
memorychip - Alias not found.
also would this work in dos?
I want to use this before running a ghost command and load an image. So this would need to have minimal software and minimal backbone.
Thanks
-
sorry i dont know it will work in DOS i used it on Vista and XP
-
the real problem I have is I need to parse the output of mem.exe for the memory level using batch commands.
Any ideas would be very helpful
-
a combination of FIND and a FOR loop with an appropriate "tokens=" entry should do it. An interesting little project for you. I wish you good luck.
-
Yeah its just I really having a hard time understanding the useing them to get what I am looking for.
I was hoping that someone might have done a project like this and would be willing to help me.
-
Well so far I have
mem>output.txt
that leaves me with:
655360 bytes total conventional memory
655360 bytes available to MS-DOS
583344 largest executable program size
1048576 bytes total contiguous extended memory
0 bytes available contiguous extended memory
941056 bytes available XMS memory
MS-DOS resident in High Memory Area
But how can i eliminate everything but
1048576
and then compare that to a constant to steer the flow of the batch?
-
The trouble is...
Mem is an MS-DOS program. It seems clear from the output you posted that you were running Win2K/XP/Vista command prompt (which is not MS-DOS).
The practical consequences of this are that, to cut a long story short, you are not seeing the total RAM installed, you are seeing the amount of contiguous extended memory which Windows has allocated to an MS-DOS virtual machine, which is a standard amount, namely 1 megabyte. That is what 1048576 bytes is. Hadn't you noticed that?
If you are running a batch file under Win2K/XP/Vista, you might as well not bother checking, because the answer is always going to be 1048576 bytes.
if you want to know the total amount of physical RAM installed on the motherboard (why?) you will have to use another command, such as systeminfo.
If you are using genuine MS-DOS then a complete rethink will be necessary. You cannot use NT command prompt techniques in MS-DOS. You need to state what OS you intend using.
-
alright I feel very dumb.
My problem is I need to find the total amount of RAM before I run a command to ghost a system
The problem is I need the batch to NOT run the ghost command if the system has below a certain amount of RAM installed.
This would be in a batch file.
The only thing I dont know how to do is how to make the value of RAM a varable that I can compare.
-
OK I'm with you now! ;) I have done a bit of Ghosting so i will have a look at some stuff and get back to you.
By the way, what version of Ghost are you running? The DOS executable ghost.exe needs very little memory by today's standards. I am curious about why you need to do this.
-
its not actually about the ghost software its about the image and the image os needed 512 Mb of RAM.
the end users are very dumb and we need a way to stop them from using a recovery disc that will just waste time.
-
Does Ghost run in a true DOS environment, or command prompt under Windows? It looks like you are probably running GHOST32.EXE in a command prompt under Windows. If this is the case, you can try:
@echo off
setlocal
for /f "tokens=2* delims=:" %%a in ('systeminfo ^| findstr /I /C:"Total Physical Memory"') do set TotalRAM=%%a
echo Total RAM is: %TotalRam%
-
Yes, I was thinking along those lines, but I think what happened was that jdogherman had been trying out the mem command under a windows environment, but the situation he (or she) envisages is the use of a recovery disk to deploy a Ghost image under MS-DOS. However I believe that later versions of Ghost (after 9) can use a 32 bit Windows PE environment, so clarification from jdogherman would be useful.
I wrote a Qbasic program which can parse the output of mem /d in a pure MS-DOS environment and find the total RAM installed, but it depends on mem writing a text file, which of course bootable CD's don't allow, and a RAM disk would probably mess with EMS and stall Ghost.exe.
-
yeah this would be on a ghost disc created and then ran. so not under the win32 enviroment.
I am using Ghost ver. 8.
I wound't know how it would act in a ram disc but it would at least get me that much closer to working with it.
If yo have any other ideas le me know thanks,
Justin
-
I once made a boot CD that created a RAM disk and then copied a lot of utilities into it. The idea was to have a user menu for the different utilities and having them on the RAM disk would make them load quicker than they would off the CD. This turned out to be a "solution" that created more problems than it solved. The main drawbacks were that creating the RAM disk and copying stuff into it off the CD took quite a long time, causing a tedious wait before you could do anything, and also that the RAM disk was created in extended memory and some programs (Ghost 8 in particular) like to have exclusive access to EMS, and refuse to run otherwise.
However, all the solutions I have come up with so far require the batch file to have access to a writable medium of some sort.
Other problems that I wonder about are: The version of DOS used to prepare the bootable disk - the MEM in some versions of DOS cannot detect RAM above 64 Mb and report all amounts equal to or greater than that as 64 MB. (My bootable pen drive uses DOS 7 that comes with Windows 98SE and reports 1 Gb of RAM correctly) and the slightly differing output formats of different MEM versions.
-
Im just so suprised that there isnt any other method to getting the amount of ram in a system.
does anyone know how to do it with simple programming to create a self contained executable?
-
Any Ideas?
-
The problem is that MS-DOS was designed a long time ago and uses 16 bit arithmetic; it is possible in theory to read the memory size from the CMOS memory using assembly language but this method runs out of steam at 64 Mb and reports all sizes over that as 64 Mb.
How many machines are you responsible for, and how many have under 512 Mb?
-
I belive this may run off of a msdos built around win 98 recovery disc.
Does anyone know of a way to write a program .exe that could do the job of the batch easier?
I am working on this project to try and improve the current configuration. We own/manage thousands of computers at remote locations. Try are we may to keep them updated and to not send image cd to a low memory computer it still happens.
Do you know of any other image methods other than what I am using that could make this easier? GHOST 8.0. It must be fool proof as our end user is not very computer savvy.
Thanks
-
alright...
What about a new boot system? placing the ghost.exe in a live disc. would that work? then in this new environment I could run a memory check.
Any one have experience with this?
-
Do the PCs have floppy drives?
-
nope
some have dvd but all have cds