How do I bypass restrictions on the length of the PATH variable

System Properties
This environment variable is too large. This dialog allows setting values up to 2047 characters long.
I use/have used a lot of software, and my PATH has grown as a result. When I try to add new paths, I get the above message. As a workaround, I'm editing my user path, but prefer not to.
windows-10 environment-variables path
add a comment |

System Properties
This environment variable is too large. This dialog allows setting values up to 2047 characters long.
I use/have used a lot of software, and my PATH has grown as a result. When I try to add new paths, I get the above message. As a workaround, I'm editing my user path, but prefer not to.
windows-10 environment-variables path
In future posts, please add the text of the error message, which I assume you already searched for to confirm the question was not asked earlier ;-) Often, just hitting Ctrl+C in such dialog will copy it for you.
– Arjan
Dec 19 '18 at 9:54
add a comment |

System Properties
This environment variable is too large. This dialog allows setting values up to 2047 characters long.
I use/have used a lot of software, and my PATH has grown as a result. When I try to add new paths, I get the above message. As a workaround, I'm editing my user path, but prefer not to.
windows-10 environment-variables path

System Properties
This environment variable is too large. This dialog allows setting values up to 2047 characters long.
I use/have used a lot of software, and my PATH has grown as a result. When I try to add new paths, I get the above message. As a workaround, I'm editing my user path, but prefer not to.
windows-10 environment-variables path
windows-10 environment-variables path
edited Dec 19 '18 at 9:53
Arjan
26.9k1065107
26.9k1065107
asked Dec 19 '18 at 9:48
Tobi AlafinTobi Alafin
1216
1216
In future posts, please add the text of the error message, which I assume you already searched for to confirm the question was not asked earlier ;-) Often, just hitting Ctrl+C in such dialog will copy it for you.
– Arjan
Dec 19 '18 at 9:54
add a comment |
In future posts, please add the text of the error message, which I assume you already searched for to confirm the question was not asked earlier ;-) Often, just hitting Ctrl+C in such dialog will copy it for you.
– Arjan
Dec 19 '18 at 9:54
In future posts, please add the text of the error message, which I assume you already searched for to confirm the question was not asked earlier ;-) Often, just hitting Ctrl+C in such dialog will copy it for you.
– Arjan
Dec 19 '18 at 9:54
In future posts, please add the text of the error message, which I assume you already searched for to confirm the question was not asked earlier ;-) Often, just hitting Ctrl+C in such dialog will copy it for you.
– Arjan
Dec 19 '18 at 9:54
add a comment |
1 Answer
1
active
oldest
votes
Microsoft's documentation says that an environment variable on Windows is limited to
only 32,767 characters
(link),
but does not say how to create such a long variable.
The problem here is that the tools that Windows provides all have their
limits :
The set and setx commands truncate values to 1023 characters.
Setting directly in the registry at
HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlSession ManagerEnvironment
fails since regedit truncates entered strings after 2047 characters.
So you must use workarounds.
Use short folder names
You may see such names by using dir /x /ad.
The following example shows that on my computer the folder Program Files (x86)
may be replaced by PROGRA~2:

Use embedded environmental variables
If you have:
C:this_is_along_paththat_appearsin_multiple_placessubdir1
C:this_is_along_paththat_appearsin_multiple_placessubdir2
then you can create a new environment variable such as:
SET P1=C:this_is_along_paththat_appearsin_multiple_places
after which your original paths become
%P1%subdir1
%P1%subdir2
You may also split PATH into two by creating a new variable, say NEWPATH,
containing the excess paths and append ;%NEWPATH% to the PATH variable.
Avoid using the
setx command
because it will directly resolve embedded environmental variables
and the resulting string will be once again too long.
Use a PowerShell script to set the PATH
PowerShell calls Windows API directly and so can approach the theoretical limit
of 32,767 characters for an environmental variable.
The script may contain commands such as:
[Environment]::SetEnvironmentVariable("Path", $longpath, "Machine")
Thank you very much. Of all of these, the %NEWPATH% option is the most palatable, so I think I'll go with that.
– Tobi Alafin
Dec 19 '18 at 12:27
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1385854%2fhow-do-i-bypass-restrictions-on-the-length-of-the-path-variable%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Microsoft's documentation says that an environment variable on Windows is limited to
only 32,767 characters
(link),
but does not say how to create such a long variable.
The problem here is that the tools that Windows provides all have their
limits :
The set and setx commands truncate values to 1023 characters.
Setting directly in the registry at
HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlSession ManagerEnvironment
fails since regedit truncates entered strings after 2047 characters.
So you must use workarounds.
Use short folder names
You may see such names by using dir /x /ad.
The following example shows that on my computer the folder Program Files (x86)
may be replaced by PROGRA~2:

Use embedded environmental variables
If you have:
C:this_is_along_paththat_appearsin_multiple_placessubdir1
C:this_is_along_paththat_appearsin_multiple_placessubdir2
then you can create a new environment variable such as:
SET P1=C:this_is_along_paththat_appearsin_multiple_places
after which your original paths become
%P1%subdir1
%P1%subdir2
You may also split PATH into two by creating a new variable, say NEWPATH,
containing the excess paths and append ;%NEWPATH% to the PATH variable.
Avoid using the
setx command
because it will directly resolve embedded environmental variables
and the resulting string will be once again too long.
Use a PowerShell script to set the PATH
PowerShell calls Windows API directly and so can approach the theoretical limit
of 32,767 characters for an environmental variable.
The script may contain commands such as:
[Environment]::SetEnvironmentVariable("Path", $longpath, "Machine")
Thank you very much. Of all of these, the %NEWPATH% option is the most palatable, so I think I'll go with that.
– Tobi Alafin
Dec 19 '18 at 12:27
add a comment |
Microsoft's documentation says that an environment variable on Windows is limited to
only 32,767 characters
(link),
but does not say how to create such a long variable.
The problem here is that the tools that Windows provides all have their
limits :
The set and setx commands truncate values to 1023 characters.
Setting directly in the registry at
HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlSession ManagerEnvironment
fails since regedit truncates entered strings after 2047 characters.
So you must use workarounds.
Use short folder names
You may see such names by using dir /x /ad.
The following example shows that on my computer the folder Program Files (x86)
may be replaced by PROGRA~2:

Use embedded environmental variables
If you have:
C:this_is_along_paththat_appearsin_multiple_placessubdir1
C:this_is_along_paththat_appearsin_multiple_placessubdir2
then you can create a new environment variable such as:
SET P1=C:this_is_along_paththat_appearsin_multiple_places
after which your original paths become
%P1%subdir1
%P1%subdir2
You may also split PATH into two by creating a new variable, say NEWPATH,
containing the excess paths and append ;%NEWPATH% to the PATH variable.
Avoid using the
setx command
because it will directly resolve embedded environmental variables
and the resulting string will be once again too long.
Use a PowerShell script to set the PATH
PowerShell calls Windows API directly and so can approach the theoretical limit
of 32,767 characters for an environmental variable.
The script may contain commands such as:
[Environment]::SetEnvironmentVariable("Path", $longpath, "Machine")
Thank you very much. Of all of these, the %NEWPATH% option is the most palatable, so I think I'll go with that.
– Tobi Alafin
Dec 19 '18 at 12:27
add a comment |
Microsoft's documentation says that an environment variable on Windows is limited to
only 32,767 characters
(link),
but does not say how to create such a long variable.
The problem here is that the tools that Windows provides all have their
limits :
The set and setx commands truncate values to 1023 characters.
Setting directly in the registry at
HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlSession ManagerEnvironment
fails since regedit truncates entered strings after 2047 characters.
So you must use workarounds.
Use short folder names
You may see such names by using dir /x /ad.
The following example shows that on my computer the folder Program Files (x86)
may be replaced by PROGRA~2:

Use embedded environmental variables
If you have:
C:this_is_along_paththat_appearsin_multiple_placessubdir1
C:this_is_along_paththat_appearsin_multiple_placessubdir2
then you can create a new environment variable such as:
SET P1=C:this_is_along_paththat_appearsin_multiple_places
after which your original paths become
%P1%subdir1
%P1%subdir2
You may also split PATH into two by creating a new variable, say NEWPATH,
containing the excess paths and append ;%NEWPATH% to the PATH variable.
Avoid using the
setx command
because it will directly resolve embedded environmental variables
and the resulting string will be once again too long.
Use a PowerShell script to set the PATH
PowerShell calls Windows API directly and so can approach the theoretical limit
of 32,767 characters for an environmental variable.
The script may contain commands such as:
[Environment]::SetEnvironmentVariable("Path", $longpath, "Machine")
Microsoft's documentation says that an environment variable on Windows is limited to
only 32,767 characters
(link),
but does not say how to create such a long variable.
The problem here is that the tools that Windows provides all have their
limits :
The set and setx commands truncate values to 1023 characters.
Setting directly in the registry at
HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlSession ManagerEnvironment
fails since regedit truncates entered strings after 2047 characters.
So you must use workarounds.
Use short folder names
You may see such names by using dir /x /ad.
The following example shows that on my computer the folder Program Files (x86)
may be replaced by PROGRA~2:

Use embedded environmental variables
If you have:
C:this_is_along_paththat_appearsin_multiple_placessubdir1
C:this_is_along_paththat_appearsin_multiple_placessubdir2
then you can create a new environment variable such as:
SET P1=C:this_is_along_paththat_appearsin_multiple_places
after which your original paths become
%P1%subdir1
%P1%subdir2
You may also split PATH into two by creating a new variable, say NEWPATH,
containing the excess paths and append ;%NEWPATH% to the PATH variable.
Avoid using the
setx command
because it will directly resolve embedded environmental variables
and the resulting string will be once again too long.
Use a PowerShell script to set the PATH
PowerShell calls Windows API directly and so can approach the theoretical limit
of 32,767 characters for an environmental variable.
The script may contain commands such as:
[Environment]::SetEnvironmentVariable("Path", $longpath, "Machine")
answered Dec 19 '18 at 10:53
harrymcharrymc
256k14267567
256k14267567
Thank you very much. Of all of these, the %NEWPATH% option is the most palatable, so I think I'll go with that.
– Tobi Alafin
Dec 19 '18 at 12:27
add a comment |
Thank you very much. Of all of these, the %NEWPATH% option is the most palatable, so I think I'll go with that.
– Tobi Alafin
Dec 19 '18 at 12:27
Thank you very much. Of all of these, the %NEWPATH% option is the most palatable, so I think I'll go with that.
– Tobi Alafin
Dec 19 '18 at 12:27
Thank you very much. Of all of these, the %NEWPATH% option is the most palatable, so I think I'll go with that.
– Tobi Alafin
Dec 19 '18 at 12:27
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1385854%2fhow-do-i-bypass-restrictions-on-the-length-of-the-path-variable%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
In future posts, please add the text of the error message, which I assume you already searched for to confirm the question was not asked earlier ;-) Often, just hitting Ctrl+C in such dialog will copy it for you.
– Arjan
Dec 19 '18 at 9:54