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

Author Topic: modify a environmental variable with a bat  (Read 3899 times)

0 Members and 1 Guest are viewing this topic.

Esgrimidor

    Topic Starter


    Hopeful

    Thanked: 1
    modify a environmental variable with a bat
    « on: September 14, 2009, 05:16:59 PM »


    Mi PC - properties (propiedades) - Advanced options (opciones avanzadas) - environmental variables (variables de entorno) - ....

    Can I modify an environmental variable (user variable or system variable) with a script ?

    a bat or vbs .... ?

    Thanksxxxx

    No dejes que tu felicidad dependa de lo que no depende de tí.

    Salmon Trout

    • Guest
    Re: modify a environmental variable with a bat
    « Reply #1 on: September 15, 2009, 01:04:30 AM »
    setx; see other thread

    Esgrimidor

      Topic Starter


      Hopeful

      Thanked: 1
      Re: modify a environmental variable with a bat
      « Reply #2 on: September 20, 2009, 03:35:19 PM »
      Working Salmon Trout.

      The first time don't go well because I don't exit the bat.

      But now goes well perfectly.

      And I think a reg writing the environmental variable to the registry gives good result also.

      What do you think ?

       :P
      No dejes que tu felicidad dependa de lo que no depende de tí.

      Salmon Trout

      • Guest
      Re: modify a environmental variable with a bat
      « Reply #3 on: September 20, 2009, 03:38:08 PM »
      Working Salmon Trout.

      The first time don't go well because I don't exit the bat.

      But now goes well perfectly.

      And I think a reg writing the environmental variable to the registry gives good result also.

      What do you think ?

       :P

      Yes, if that is easier; modifying the registry is what setx actually does. And what modifying environment variables in Control Panel does.

      Esgrimidor

        Topic Starter


        Hopeful

        Thanked: 1
        Re: modify a environmental variable with a bat
        « Reply #4 on: September 20, 2009, 06:05:28 PM »
        I'm trying with no good result propose the environmental variable in an excell cell.

        With the function environ()
        But I do bad.


        If I want propose the cell D52 and the variable varexpediente what can I do ?

        I have tried =environ("varexpediente") with no results

         ::)
        No dejes que tu felicidad dependa de lo que no depende de tí.

        Salmon Trout

        • Guest
        Re: modify a environmental variable with a bat
        « Reply #5 on: September 21, 2009, 12:53:43 AM »
        Did you use the Macro Editor and create a VBA function (like I showed you in the other thread)?

        here: http://www.computerhope.com/forum/index.php/topic,90865.0.html





        inapaler



          Rookie

          Thanked: 1
          Re: modify a environmental variable with a bat
          « Reply #6 on: September 21, 2009, 04:24:21 AM »
          I like it...

          this really good..
          Thanks  a lot.

          Esgrimidor

            Topic Starter


            Hopeful

            Thanked: 1
            Re: modify a environmental variable with a bat
            « Reply #7 on: September 21, 2009, 11:58:28 AM »


            You are completely right. I need revise the other post.

             :P

            There is a lot of important information I have to study.

            the information about the txt file (or ini file perhaps) I think is very revealing.




            No dejes que tu felicidad dependa de lo que no depende de tí.

            Salmon Trout

            • Guest
            Re: modify a environmental variable with a bat
            « Reply #8 on: September 21, 2009, 12:04:55 PM »
            en garde!

            Esgrimidor

              Topic Starter


              Hopeful

              Thanked: 1
              Re: modify a environmental variable with a bat
              « Reply #9 on: September 21, 2009, 06:41:56 PM »
              I have been making a lot of proofs and seemed to be :

              1. I used setx for changing environmental variables. And get it because examining Mi PC - properties..... . I observ the new value.

              but inside excel seem not to be affected, or the bat created to execute the word doc with the variable path.

              It's this correct. The change is not instantanous.....

              2. I use a .reg file to change the environmental variable with good results, but this change seem take not effect in my bat file or inside excel.


              So I'll try to close user session or reiniate the system and comment. ......





              Edited : The problem is that the variables are not refreshed instanly in excel.

              1. Really I don't need reiniate o close user session. What I did to obtain the actual value of varexpediente in the excel cells was re-write in the cells the name of the variable or the formula and goes well. .....

              There is no way of appearing instanly the new value of the variable varexpediente ?

              2. The other method with the text file goes well. I obtain instanly the same result in the cell, in the hyperlink and in the text file .txt .


              « Last Edit: September 21, 2009, 07:17:22 PM by Esgrimidor »
              No dejes que tu felicidad dependa de lo que no depende de tí.