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

Author Topic: variables help  (Read 6138 times)

0 Members and 1 Guest are viewing this topic.

feras

    Topic Starter


    Beginner

    Thanked: 1
  • Experience: Experienced
  • OS: Linux variant
variables help
« on: February 19, 2009, 09:59:02 AM »
HI  :)

I have an important Q

How can I determine a lasting variable
so cmd remember the value of this variable after batch file exit

please guide me

BatchRocks



    Hopeful
  • Thanked: 3
    Re: variables help
    « Reply #1 on: February 19, 2009, 09:59:31 AM »
    set in CMD.

    feras

      Topic Starter


      Beginner

      Thanked: 1
    • Experience: Experienced
    • OS: Linux variant
    Re: variables help
    « Reply #2 on: February 19, 2009, 10:05:20 AM »
    thank you

    but i don,t mean the "orginal" variables

    I want to set another

    for example:

    Code: [Select]
    set/p "name=>"
    >feras

    if I exit cmd.exe , run it again and when type

    Code: [Select]
    echo %name%

    NO result


    BatchRocks



      Hopeful
    • Thanked: 3
      Re: variables help
      « Reply #3 on: February 19, 2009, 10:25:15 AM »
      Set /p name=
      echo %name%

      feras

        Topic Starter


        Beginner

        Thanked: 1
      • Experience: Experienced
      • OS: Linux variant
      Re: variables help
      « Reply #4 on: February 19, 2009, 10:34:09 AM »
      sorry but no result too

      that code eill not set lasting variable

      any solution?

      thank you  :)

      BatchRocks



        Hopeful
      • Thanked: 3
        Re: variables help
        « Reply #5 on: February 19, 2009, 10:35:59 AM »
        You did Start > Run > cmd.exe

        Typed in set /p name=
        then typed in anything,
        then did echo %name%?

        BR

        feras

          Topic Starter


          Beginner

          Thanked: 1
        • Experience: Experienced
        • OS: Linux variant
        Re: variables help
        « Reply #6 on: February 19, 2009, 10:40:37 AM »
        yes

        that is

        BatchRocks



          Hopeful
        • Thanked: 3
          Re: variables help
          « Reply #7 on: February 19, 2009, 10:40:58 AM »
          It worked  :D?

          feras

            Topic Starter


            Beginner

            Thanked: 1
          • Experience: Experienced
          • OS: Linux variant
          Re: variables help
          « Reply #8 on: February 19, 2009, 10:42:56 AM »
          mm

          no too

          are you sure the variable %name% will work after system restart?

          BatchRocks



            Hopeful
          • Thanked: 3
            Re: variables help
            « Reply #9 on: February 19, 2009, 10:44:54 AM »
            Start > Run > cmd.exe

            Type in the following:

            Code: [Select]
            set /p name=
            Hello
            echo %name%

            After set /p name= hit enter, type Hello, enter, type echo %name%, enter.

            feras

              Topic Starter


              Beginner

              Thanked: 1
            • Experience: Experienced
            • OS: Linux variant
            Re: variables help
            « Reply #10 on: February 19, 2009, 10:48:23 AM »
            that is ok this code works

            but I want to use the variable name again without needing to reset it again

            so DOS will remember that %name%=Hello even if I restart the system

            is that possible

            Dias de verano

            • Guest
            Re: variables help
            « Reply #11 on: February 19, 2009, 11:50:11 AM »
            that is ok this code works

            but I want to use the variable name again without needing to reset it again

            so DOS will remember that %name%=Hello even if I restart the system

            is that possible

            You have not stated your OS. In XP:

            1. Right click My Computer
            2. Click Properties
            3. Click Advanced
            4. Click Environment Variables
            5. Decide if variable is to be for current user, or all users.
            6. If current user click New in User Variables section (upper).
            7. If all users click New in Environment Variables section (lower).
            8. Enter variable name and value
            9. Click all the OK buttons until done.
            9. Following reboot, variable will be set at every startup.
            10. Check variable with Set command at prompt.



            Code: [Select]
            C:\>set
            ALLUSERSPROFILE=C:\Documents and Settings\All Users
            APPDATA=C:\Documents and Settings\Precoce\Application Data
            CLASSPATH=.;C:\Program Files\Java\jre1.5.0_04\lib\ext\QTJava.zip
            CommonProgramFiles=C:\Program Files\Common Files
            COMPUTERNAME=PUPP-C92F25ED23
            ComSpec=C:\WINDOWS\system32\cmd.exe
            ConsoleTextColor=Enabled by Colors
            ConsoleTextColor.Bold=F6
            ConsoleTextColor.Caption=F3
            ConsoleTextColor.Container=F9
            ConsoleTextColor.Disabled=FC
            ConsoleTextColor.Enabled=FA
            ConsoleTextColor.Error=FC
            ConsoleTextColor.Normal=F0
            ConsoleTextColor.Soft=F7
            dircmd=/OG
            FP_NO_HOST_CHECK=NO
            HOMEDRIVE=C:
            HOMEPATH=\Documents and Settings\Precoce
            INPUTRC=c:\program files\ruby\bin\inputrc.euro
            LOGONSERVER=\\PUPP-C92F25ED23
            MyVar=Hello Kitty <-----------------------------------------------------------------------------
            NUMBER_OF_PROCESSORS=2
            OS=Windows_NT
            Path=C:\;C:\WINDOWS;C:\WINDOWS\system32;C:\WINDOWS\System32\Wbem;c:\batch;C:\utils;c:\program files\ruby\bin;C:\Program Files\Window
            s Resource Kits\Tools
            PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.PSC1;.RB;.RBW;.tcl
            PROCESSOR_ARCHITECTURE=x86
            PROCESSOR_IDENTIFIER=x86 Family 15 Model 3 Stepping 4, GenuineIntel
            PROCESSOR_LEVEL=15
            PROCESSOR_REVISION=0304
            ProgramFiles=C:\Program Files
            Prompt=$P$G
            QTJAVA=C:\Program Files\Java\jre1.5.0_04\lib\ext\QTJava.zip
            RUBYOPT=-rubygems
            SESSIONNAME=Console
            SystemDrive=C:
            SystemRoot=C:\WINDOWS
            TEMP=C:\DOCUME~1\Precoce\LOCALS~1\Temp
            TMP=C:\DOCUME~1\Precoce\LOCALS~1\Temp
            USERDOMAIN=PUPP-C92F25ED23
            USERNAME=Precoce
            USERPROFILE=C:\Documents and Settings\Precoce
            VBScriptFolder=C:\batch\VBScripts
            windir=C:\WINDOWS

            feras

              Topic Starter


              Beginner

              Thanked: 1
            • Experience: Experienced
            • OS: Linux variant
            Re: variables help
            « Reply #12 on: February 20, 2009, 09:02:49 AM »
            Thanks M.r Dias de verano

            I know this way

            How can I do it in DOS mode?

            BatchRocks



              Hopeful
            • Thanked: 3
              Re: variables help
              « Reply #13 on: February 20, 2009, 09:17:05 AM »
              Thanks M.r Dias de verano

              I know this way

              How can I do it in DOS mode?

              Where you put "Variable name", do echo %varname%

              Lets say you put Var Name is...Cow, then do

              echo %cow%

              You get it...

              BC_Programmer


                Mastermind
              • Typing is no substitute for thinking.
              • Thanked: 1140
                • Yes
                • Yes
                • BC-Programming.com
              • Certifications: List
              • Computer: Specs
              • Experience: Beginner
              • OS: Windows 11
              Re: variables help
              « Reply #14 on: February 20, 2009, 09:33:43 AM »
              Thanks M.r Dias de verano

              I know this way

              How can I do it in DOS mode?

              Where you put "Variable name", do echo %varname%

              Lets say you put Var Name is...Cow, then do

              echo %cow%

              You get it...

              they want to know how to SET variables so that they are persistent between sessions.

              AFAIK not possible.
              I was trying to dereference Null Pointers before it was cool.