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 18697 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