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 14377 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.