Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Batch to check for TOTAL RAM  (Read 18696 times)

0 Members and 1 Guest are viewing this topic.

jdogherman

    Topic Starter


    Rookie

    Batch to check for TOTAL RAM
    « 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

    devcom



      Apprentice

      Thanked: 37
      Re: Batch to check for TOTAL RAM
      « Reply #1 on: March 27, 2008, 02:37:38 PM »
      try somethink like this:
      Code: [Select]
      wmic memorychip get /VALUE |findstr "Capacity"and notice that the Capacity is in kb
      Download: Choice.exe

      jdogherman

        Topic Starter


        Rookie

        Re: Batch to check for TOTAL RAM
        « Reply #2 on: March 27, 2008, 02:47:50 PM »
        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

        devcom



          Apprentice

          Thanked: 37
          Re: Batch to check for TOTAL RAM
          « Reply #3 on: March 27, 2008, 03:22:00 PM »
          sorry i dont know it will work in DOS i used it on Vista and XP
          Download: Choice.exe

          jdogherman

            Topic Starter


            Rookie

            Re: Batch to check for TOTAL RAM
            « Reply #4 on: March 28, 2008, 07:38:27 AM »
            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

            Dias de verano

            • Guest
            Re: Batch to check for TOTAL RAM
            « Reply #5 on: March 28, 2008, 07:43:27 AM »
            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.

            jdogherman

              Topic Starter


              Rookie

              Re: Batch to check for TOTAL RAM
              « Reply #6 on: March 28, 2008, 07:48:47 AM »
              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.

              jdogherman

                Topic Starter


                Rookie

                Re: Batch to check for TOTAL RAM
                « Reply #7 on: March 28, 2008, 08:11:47 AM »
                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?

                Dias de verano

                • Guest
                Re: Batch to check for TOTAL RAM
                « Reply #8 on: March 28, 2008, 01:49:08 PM »
                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.


                jdogherman

                  Topic Starter


                  Rookie

                  Re: Batch to check for TOTAL RAM
                  « Reply #9 on: March 28, 2008, 02:03:03 PM »
                  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.

                  Dias de verano

                  • Guest
                  Re: Batch to check for TOTAL RAM
                  « Reply #10 on: March 28, 2008, 02:33:23 PM »
                  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.





                  « Last Edit: March 28, 2008, 02:52:15 PM by Dias de verano »

                  jdogherman

                    Topic Starter


                    Rookie

                    Re: Batch to check for TOTAL RAM
                    « Reply #11 on: March 28, 2008, 02:58:16 PM »
                    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.

                    GuruGary



                      Adviser
                      Re: Batch to check for TOTAL RAM
                      « Reply #12 on: March 29, 2008, 10:24:06 AM »
                      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:
                      Code: [Select]
                      @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%

                      Dias de verano

                      • Guest
                      Re: Batch to check for TOTAL RAM
                      « Reply #13 on: March 29, 2008, 11:26:18 AM »
                      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.

                      jdogherman

                        Topic Starter


                        Rookie

                        Re: Batch to check for TOTAL RAM
                        « Reply #14 on: March 29, 2008, 07:55:28 PM »
                        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

                        Dias de verano

                        • Guest
                        Re: Batch to check for TOTAL RAM
                        « Reply #15 on: March 30, 2008, 04:25:47 AM »
                        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.



                        jdogherman

                          Topic Starter


                          Rookie

                          Re: Batch to check for TOTAL RAM
                          « Reply #16 on: March 30, 2008, 08:20:01 AM »
                          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?



                          jdogherman

                            Topic Starter


                            Rookie

                            Re: Batch to check for TOTAL RAM
                            « Reply #17 on: April 05, 2008, 10:27:10 PM »
                            Any Ideas?

                            Dias de verano

                            • Guest
                            Re: Batch to check for TOTAL RAM
                            « Reply #18 on: April 06, 2008, 02:04:10 AM »
                            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?

                            jdogherman

                              Topic Starter


                              Rookie

                              Re: Batch to check for TOTAL RAM
                              « Reply #19 on: April 06, 2008, 07:13:13 AM »
                              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

                              jdogherman

                                Topic Starter


                                Rookie

                                Re: Batch to check for TOTAL RAM
                                « Reply #20 on: April 06, 2008, 08:05:04 AM »
                                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?

                                Dias de verano

                                • Guest
                                Re: Batch to check for TOTAL RAM
                                « Reply #21 on: April 06, 2008, 08:09:42 AM »
                                Do the PCs have floppy drives?

                                jdogherman

                                  Topic Starter


                                  Rookie

                                  Re: Batch to check for TOTAL RAM
                                  « Reply #22 on: April 06, 2008, 08:20:17 AM »
                                  nope

                                  some have dvd but all have cds