The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,860 other subscribers

Adding entries to the PATH persistently (be aware of the 1024 character limit of SETX)

Posted by jpluimers on 2025/01/08

Directly after a new Windows installation, I want to have my cloned git repository of batch files in the PATH persistently so that it gets searched after rebooting or opening a new console window.

At that moment, there is not much of a 1024 PATH character limitation, but be aware about that limit if you try this yourself.

This is my add-current-directory-to-path-at-end.persistent-and-limit-to-1024-characters.bat:

:: https://serverfault.com/questions/664180/can-i-permanently-add-to-path-in-windows-using-batch
:: https://superuser.com/questions/812754/how-to-recover-from-path-being-truncated-to-1024-characters-by-setx
:: global environment
setx PATH "%PATH%;%CD%"
:: local process
:: https://superuser.com/questions/975605/add-current-directory-to-path
set PATH=%PATH%;%CD%

I execute it from within the cloned git directory.

Oh: you need to double-quote the SETX parameters, otherwise you get an error message: “ERROR: Invalid syntax. Default option is not allowed more than '2' time(s).“.

More links than the above ones from the batch file, especially on the 1024 character limitation:

Queries:

--jeroen

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.