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

Author Topic: Permanently change the PATH from within a DOS Batch File  (Read 14371 times)

0 Members and 1 Guest are viewing this topic.

iONik

    Topic Starter


    Beginner

    Permanently change the PATH from within a DOS Batch File
    « on: April 13, 2009, 08:50:44 AM »
    I'd like to permanently change the PATH of a Windows XP system using a DOS Batch file.

    The syntax I came up with was:

    FROM:
    Code: [Select]
    set PATH=%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem
    TO:
    Code: [Select]
    set PATH=%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SystemRoot%\NewPathDIR\
    Is this correct?
    Would I need to reboot before the changes take effect?

    It doesn't appear to be working.

    The code I am using is:
    Code: [Select]
    @ECHO OFF
    CLS
    PATH
    echo.
    echo The Current PATH
    Pause
    set PATH=%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SystemRoot%\system\sysbats;C:\WINDOWS\system32\WindowsPowerShell\v1.0
    PATH
    echo.
    echo The New PATH
    Pause

    mroilfield



      Mentor
    • Thanked: 42
      • Yes
      • Yes
    • Computer: Specs
    • Experience: Experienced
    • OS: Windows 11
    Re: Permanently change the PATH from within a DOS Batch File
    « Reply #1 on: April 13, 2009, 08:55:22 AM »
    I am not very familiar with batch codes so what exactly is this supposed to do?
    You can't fix Stupid!!!

    Dias de verano

    • Guest
    Re: Permanently change the PATH from within a DOS Batch File
    « Reply #2 on: April 13, 2009, 09:09:53 AM »
    I'd like to permanently change the PATH of a Windows XP system using a DOS Batch file.

    The syntax I came up with was:

    FROM:
    Code: [Select]
    set PATH=%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem
    TO:
    Code: [Select]
    set PATH=%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SystemRoot%\NewPathDIR\
    Is this correct?

    You do not need the trailing slash

    It will change the path but only during that console session.

    To change the PATH variable permanently :

    My Computer - Properties - Advanced - Environment Variables

    or

    Control Panel - System - Advanced - Environment variables

    Reboot.

    Dias de verano

    • Guest
    Re: Permanently change the PATH from within a DOS Batch File
    « Reply #3 on: April 13, 2009, 09:10:42 AM »
    I am not very familiar with batch codes so what exactly is this supposed to do?


    So why are you posting?

    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: Permanently change the PATH from within a DOS Batch File
    « Reply #4 on: April 13, 2009, 09:15:54 AM »
    so he can learn maybe?

    Also, I heard there is a lot of money in automating the processes performed by the monkey.
    I was trying to dereference Null Pointers before it was cool.

    iONik

      Topic Starter


      Beginner

      Re: Permanently change the PATH from within a DOS Batch File
      « Reply #5 on: April 13, 2009, 09:16:15 AM »
      You do not need the trailing slash

      It will change the path but only during that console session.

      To change the PATH variable permanently :

      My Computer - Properties - Advanced - Environment Variables

      or

      Control Panel - System - Advanced - Environment variables

      Reboot.


      In other words it will change the path for the current DOS session. Once I exit the DOS window it will be lost.


      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: Permanently change the PATH from within a DOS Batch File
      « Reply #6 on: April 13, 2009, 09:17:06 AM »
      yes.

      The alternate solution provided would work though.
      I was trying to dereference Null Pointers before it was cool.

      iONik

        Topic Starter


        Beginner

        Re: Permanently change the PATH from within a DOS Batch File
        « Reply #7 on: April 13, 2009, 09:17:37 AM »
        I am not very familiar with batch codes so what exactly is this supposed to do?


        The title should have explained it!!!!  I would have thought...

        iONik

          Topic Starter


          Beginner

          Re: Permanently change the PATH from within a DOS Batch File
          « Reply #8 on: April 13, 2009, 09:20:09 AM »
          yes.

          The alternate solution provided would work though.

          That kinda stinks.

          I do know about the "alternate" solution, but was hoping to automate the "monkey process"!

          Thanks

          Dias de verano

          • Guest
          Re: Permanently change the PATH from within a DOS Batch File
          « Reply #9 on: April 13, 2009, 09:20:56 AM »
          In other words it will change the path for the current DOS session. Once I exit the DOS window it will be lost.

          Your example that you posted first only lasts for the current console session. To change the PATH permanently, go to either Control Panel or My Computer as I wrote.

          Dias de verano

          • Guest
          Re: Permanently change the PATH from within a DOS Batch File
          « Reply #10 on: April 13, 2009, 09:21:15 AM »
          That kinda stinks.

          I do know about the "alternate" solution, but was hoping to automate the "monkey process"!

          Thanks

          Use SETX in that case. (Google for it, it is in XP SP2 support tools)

          mroilfield



            Mentor
          • Thanked: 42
            • Yes
            • Yes
          • Computer: Specs
          • Experience: Experienced
          • OS: Windows 11
          Re: Permanently change the PATH from within a DOS Batch File
          « Reply #11 on: April 13, 2009, 09:23:12 AM »
          So why are you posting?


          Like BC said so I can try to learn.

          The title should have explained it!!!!  I would have thought...

          Well your title says you want to change a path but doesn't what path you want to change. Like I stated i am not very familiar with batch so I am trying to pick up what I can.
          You can't fix Stupid!!!

          Dias de verano

          • Guest
          Re: Permanently change the PATH from within a DOS Batch File
          « Reply #12 on: April 13, 2009, 09:24:10 AM »
          Like BC said so I can try to learn.

          Well your title says you want to change a path but doesn't what path you want to change. Like I stated i am not very familiar with batch so I am trying to pick up what I can.

          Not a path, the PATH system variable.

          iONik

            Topic Starter


            Beginner

            Re: Permanently change the PATH from within a DOS Batch File
            « Reply #13 on: April 13, 2009, 10:00:09 AM »
            Use SETX in that case. (Google for it, it is in XP SP2 support tools)


            I have SETX.EXE in my default path (C:/Windows/System32) but have no clue how this command is to do what I am asking.


            iONik

              Topic Starter


              Beginner

              Re: Permanently change the PATH from within a DOS Batch File
              « Reply #14 on: April 13, 2009, 10:08:14 AM »
              Like BC said so I can try to learn.

              Well your title says you want to change a path but doesn't what path you want to change. Like I stated i am not very familiar with batch so I am trying to pick up what I can.

              This Path would be the default search path for any system commands such as those located in C:\Windows\System32

              Examples:

              cmd.exe
              msconfig.
              append.exe
              attrib.exe
              calc.exe
              expand.exe
              ftp.exe
              runonce.exe
              rundll.exe
              sysedit.exe
              edit.com
              format.com
              command.com

              etc...etc...

              without this path(s) windows would not opperate well, if at all.


              mroilfield



                Mentor
              • Thanked: 42
                • Yes
                • Yes
              • Computer: Specs
              • Experience: Experienced
              • OS: Windows 11
              Re: Permanently change the PATH from within a DOS Batch File
              « Reply #15 on: April 13, 2009, 10:11:39 AM »
              This Path would be the default search path for any system commands such as those located in C:\Windows\System32

              Examples:

              cmd.exe
              msconfig.
              append.exe
              attrib.exe
              calc.exe
              expand.exe
              ftp.exe
              runonce.exe
              rundll.exe
              sysedit.exe
              edit.com
              format.com
              command.com

              etc...etc...

              without this path(s) windows would not opperate well, if at all.



              Thanks for the info
              You can't fix Stupid!!!

              Dias de verano

              • Guest
              Re: Permanently change the PATH from within a DOS Batch File
              « Reply #16 on: April 13, 2009, 11:29:46 AM »
              I have SETX.EXE in my default path (C:/Windows/System32) but have no clue how this command is to do what I am asking.



              setx /?

              or setx -i


              gh0std0g74



                Apprentice

                Thanked: 37
                Re: Permanently change the PATH from within a DOS Batch File
                « Reply #17 on: April 13, 2009, 06:48:19 PM »
                I'd like to permanently change the PATH of a Windows XP system using a DOS Batch file.
                you can use command line registry tools or vbscript  to change the registry setting
                HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\Path.

                iONik

                  Topic Starter


                  Beginner

                  Re: Permanently change the PATH from within a DOS Batch File
                  « Reply #18 on: April 13, 2009, 08:19:24 PM »
                  you can use command line registry tools or vbscript  to change the registry setting
                  HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\Path.

                  From the registry I exported to a file EvVar.reg

                  Code: [Select]
                  Windows Registry Editor Version 5.00

                  [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment]
                  "ComSpec"=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,\
                    74,00,25,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,63,\
                    00,6d,00,64,00,2e,00,65,00,78,00,65,00,00,00
                  "FP_NO_HOST_CHECK"="NO"
                  "NUMBER_OF_PROCESSORS"="1"
                  "OS"="Windows_NT"
                  "Path"=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,\
                    00,25,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,3b,00,25,00,\
                    53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,00,3b,00,25,\
                    00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,00,5c,00,\
                    53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,57,00,62,00,65,00,6d,\
                    00,3b,00,25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,\
                    25,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,5c,00,73,00,79,00,73,00,62,\
                    00,61,00,74,00,73,00,3b,00,43,00,3a,00,5c,00,57,00,49,00,4e,00,44,00,4f,00,\
                    57,00,53,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,57,\
                    00,69,00,6e,00,64,00,6f,00,77,00,73,00,50,00,6f,00,77,00,65,00,72,00,53,00,\
                    68,00,65,00,6c,00,6c,00,5c,00,76,00,31,00,2e,00,30,00,00,00
                  "PATHEXT"=".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.PSC1"
                  "PROCESSOR_ARCHITECTURE"="x86"
                  "PROCESSOR_IDENTIFIER"="x86 Family 6 Model 13 Stepping 8, GenuineIntel"
                  "PROCESSOR_LEVEL"="6"
                  "PROCESSOR_REVISION"="0d08"
                  "TEMP"=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,\
                    00,25,00,5c,00,54,00,45,00,4d,00,50,00,00,00
                  "TMP"=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,\
                    25,00,5c,00,54,00,45,00,4d,00,50,00,00,00
                  "windir"=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,\
                    00,25,00,00,00


                  Now would I just need an edited version with aditional environmental variables and import the reg file and restart for changes to take effect?

                  Or would I really only need the following code as the Path is all that would be altered?

                  Code: [Select]
                  Windows Registry Editor Version 5.00

                  [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment]
                  "Path"=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,\
                    00,25,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,3b,00,25,00,\
                    53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,00,3b,00,25,\
                    00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,00,5c,00,\
                    53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,57,00,62,00,65,00,6d,\
                    00,3b,00,25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,\
                    25,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,5c,00,73,00,79,00,73,00,62,\
                    00,61,00,74,00,73,00,3b,00,43,00,3a,00,5c,00,57,00,49,00,4e,00,44,00,4f,00,\
                    57,00,53,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,57,\
                    00,69,00,6e,00,64,00,6f,00,77,00,73,00,50,00,6f,00,77,00,65,00,72,00,53,00,\
                    68,00,65,00,6c,00,6c,00,5c,00,76,00,31,00,2e,00,30,00,00,00

                  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: Permanently change the PATH from within a DOS Batch File
                  « Reply #19 on: April 13, 2009, 08:22:44 PM »
                  To change the PATH variable permanently :

                  My Computer - Properties - Advanced - Environment Variables

                  or

                  Control Panel - System - Advanced - Environment variables

                  Reboot.



                  Which part did you miss the first and second time?
                  I was trying to dereference Null Pointers before it was cool.

                  gh0std0g74



                    Apprentice

                    Thanked: 37
                    Re: Permanently change the PATH from within a DOS Batch File
                    « Reply #20 on: April 13, 2009, 09:07:41 PM »
                    From the registry I exported to a file EvVar.reg

                    Code: [Select]
                    Windows Registry Editor Version 5.00

                    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment]
                    "ComSpec"=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,\
                      74,00,25,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,63,\
                      00,6d,00,64,00,2e,00,65,00,78,00,65,00,00,00
                    "FP_NO_HOST_CHECK"="NO"
                    "NUMBER_OF_PROCESSORS"="1"
                    "OS"="Windows_NT"
                    "Path"=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,\
                      00,25,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,3b,00,25,00,\
                      53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,00,3b,00,25,\
                      00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,00,5c,00,\
                      53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,57,00,62,00,65,00,6d,\
                      00,3b,00,25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,\
                      25,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,5c,00,73,00,79,00,73,00,62,\
                      00,61,00,74,00,73,00,3b,00,43,00,3a,00,5c,00,57,00,49,00,4e,00,44,00,4f,00,\
                      57,00,53,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,57,\
                      00,69,00,6e,00,64,00,6f,00,77,00,73,00,50,00,6f,00,77,00,65,00,72,00,53,00,\
                      68,00,65,00,6c,00,6c,00,5c,00,76,00,31,00,2e,00,30,00,00,00
                    "PATHEXT"=".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.PSC1"
                    "PROCESSOR_ARCHITECTURE"="x86"
                    "PROCESSOR_IDENTIFIER"="x86 Family 6 Model 13 Stepping 8, GenuineIntel"
                    "PROCESSOR_LEVEL"="6"
                    "PROCESSOR_REVISION"="0d08"
                    "TEMP"=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,\
                      00,25,00,5c,00,54,00,45,00,4d,00,50,00,00,00
                    "TMP"=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,\
                      25,00,5c,00,54,00,45,00,4d,00,50,00,00,00
                    "windir"=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,\
                      00,25,00,00,00


                    Now would I just need an edited version with aditional environmental variables and import the reg file and restart for changes to take effect?

                    Or would I really only need the following code as the Path is all that would be altered?

                    Code: [Select]
                    Windows Registry Editor Version 5.00

                    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment]
                    "Path"=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,\
                      00,25,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,3b,00,25,00,\
                      53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,00,3b,00,25,\
                      00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,00,5c,00,\
                      53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,57,00,62,00,65,00,6d,\
                      00,3b,00,25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,\
                      25,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,5c,00,73,00,79,00,73,00,62,\
                      00,61,00,74,00,73,00,3b,00,43,00,3a,00,5c,00,57,00,49,00,4e,00,44,00,4f,00,\
                      57,00,53,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,57,\
                      00,69,00,6e,00,64,00,6f,00,77,00,73,00,50,00,6f,00,77,00,65,00,72,00,53,00,\
                      68,00,65,00,6c,00,6c,00,5c,00,76,00,31,00,2e,00,30,00,00,00

                    hey man, are you going to change the PATH variable permanently that often? if not, just do it once through the control panel.
                    otherwise, i think you should read up on how reg.exe works.

                    Dias de verano

                    • Guest
                    Re: Permanently change the PATH from within a DOS Batch File
                    « Reply #21 on: April 14, 2009, 12:19:13 AM »
                    I smell a potential rat. Why monkey with the registry scriptomatically, and why is he putting the values like that in hex? Why not use the manual method of Control Panel / My Computer, or else a script with SETX?



                    iONik

                      Topic Starter


                      Beginner

                      Re: Permanently change the PATH from within a DOS Batch File
                      « Reply #22 on: April 14, 2009, 07:53:25 AM »
                      I smell a potential rat. Why monkey with the registry scriptomatically, and why is he putting the values like that in hex? Why not use the manual method of Control Panel / My Computer, or else a script with SETX?




                      If I am way off base by not just simple using "My Computer - Properties - Advanced - Environment Variables" then your sens of smell is extremely damaged. Don't read between the lines. Paranoia may tell you that something is there, but all that something is really just air.

                      I often do more OS installations than I would like and am simply trying to simplify the monkey work. I merely want to create a file with helpful batch files and such whose path is part of the system variable.

                      Registry file in HEX: That's the way it exported, that's all, no rats..,nothin' but air.

                      I guess the question is: does not the method of "My Computer - Properties - Advanced - Environment Variables" merely change the registry, and this is why I'd need a restart?

                      "or script with SETX" would anyone care to elaborate on this?


                      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: Permanently change the PATH from within a DOS Batch File
                      « Reply #23 on: April 14, 2009, 07:55:07 AM »
                      Setx?
                      I was trying to dereference Null Pointers before it was cool.

                      iONik

                        Topic Starter


                        Beginner

                        Re: Permanently change the PATH from within a DOS Batch File
                        « Reply #24 on: April 14, 2009, 08:20:13 AM »
                        SETX...

                        SETX MYPATH %PATH%
                        Sets the value of MYPATH to the CURRENT value of the PATH environment variable.

                        In other words set MYPATH =
                        %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\WINDOWS\system32\WindowsPowerShell\v1.0


                        SETX MYPATH ~PATH~
                        Sets the value of MYPATH to ALWAYS be equal to the value of the PATH environment
                        variable even in the event that the PATH variable changes.


                        SETX Registry Examples:
                        -------------------
                        SETX TZONE -k HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\TimeZoneInformation\StandardName
                        Sets the value of TZONE to the above key ie. "Central Standard Time"

                        The above examples seem only to create then set a variable to an existing value. I would like to do the opposite, set a known value from a different known variable. Or am i misreading this, hence the reason I came here in the first place...

                        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: Permanently change the PATH from within a DOS Batch File
                        « Reply #25 on: April 14, 2009, 08:21:34 AM »
                        "set" followed by the name of  the variable prints that variable.
                        I was trying to dereference Null Pointers before it was cool.

                        iONik

                          Topic Starter


                          Beginner

                          Re: Permanently change the PATH from within a DOS Batch File
                          « Reply #26 on: April 14, 2009, 08:34:35 AM »
                          Alright, Alright...

                          I'll Keep you guys from sharing a little information and help. Don't want you to fall off the precipice you stand on.

                          It is often said that the evil one sees in others is nothing but a mirror reflection of self. Thus by being so intent on exposing a "rat" in someone else it merely exposes the "rat" in oneself.

                          If my task could only be done via "My Computer - Properties - Advanced - Environment Variables" and no other way, then all would be said and done and I should have posted in the Windows XP Forum. But since I keep getting other possibilities from the gallery, I keep getting the suspicion that It can indeed be done another way, using batch code, script code, SETX code... which is why I posted in this forum for help.

                          But I will forgive you all for your poor sense of smell and not prod you any further......................

                          Cheers!

                          « Last Edit: April 14, 2009, 09:12:05 AM by iONik »

                          gh0std0g74



                            Apprentice

                            Thanked: 37
                            Re: Permanently change the PATH from within a DOS Batch File
                            « Reply #27 on: April 14, 2009, 08:46:43 AM »
                            if you have Perl , you can use Win32::TieRegistry module
                            Code: [Select]
                            use Win32::TieRegistry;
                            $path = $Registry->{"LMachine/SYSTEM/CurrentControlSet/Control/Session Manager/Environment/Path"};
                            $path = $path . ";c:\\test_directory";
                            $Registry->{"LMachine/SYSTEM/CurrentControlSet/Control/Session Manager/Environment/Path"} = $path;
                            otherwise, using setx is very straightforward, i don't see why it can't work for you.

                            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: Permanently change the PATH from within a DOS Batch File
                            « Reply #28 on: April 14, 2009, 08:54:28 AM »
                            otherwise, using setx is very straightforward, i don't see why it can't work for you.

                            apparently we're supposed to give him a whole *censored* script.
                            I was trying to dereference Null Pointers before it was cool.

                            iONik

                              Topic Starter


                              Beginner

                              Re: Permanently change the PATH from within a DOS Batch File
                              « Reply #29 on: April 15, 2009, 03:41:46 PM »
                              Here's my mountain of code to do the job I was after...

                              Code: [Select]
                              @echo off
                              set vara=%PATH%
                              set varb=;%SystemRoot%\sysfiles
                              set varc=%vara%%varb%
                              setx PATH %varc% -m
                              set vara=
                              set varb=
                              set varc=

                              not really sure the set vara=, set varb=, set varc= is necessary.


                              Dias de verano

                              • Guest
                              Re: Permanently change the PATH from within a DOS Batch File
                              « Reply #30 on: April 15, 2009, 03:48:58 PM »
                              Here's my mountain of code to do the job I was after...

                              Code: [Select]
                              @echo off
                              set vara=%PATH%
                              set varb=;%SystemRoot%\sysfiles
                              set varc=%vara%%varb%
                              setx PATH %varc% -m
                              set vara=
                              set varb=
                              set varc=

                              not really sure the set vara=, set varb=, set varc= is necessary.



                              Nope. To add \dir to path: (you append it)

                              set path "%path%;\dir"

                              see here:

                              http://www.google.co.uk/search?source=ig&hl=en&rlz=&=&q=setx+path&btnG=Google+Search&meta=lr%3D


                              iONik

                                Topic Starter


                                Beginner

                                Re: Permanently change the PATH from within a DOS Batch File
                                « Reply #31 on: April 15, 2009, 03:58:47 PM »
                                Nope. To add \dir to path: (you append it)

                                set path "%path%;\dir"

                                see here:

                                http://www.google.co.uk/search?source=ig&hl=en&rlz=&=&q=setx+path&btnG=Google+Search&meta=lr%3D



                                My "mountain of code" (not really) does do the trick, but you have cut that back about as far as it can go I'd guess.

                                But I will need SETX

                                Code: [Select]
                                setx PATH "%PATH%;C:\Windows\newdir" -m