Skip to content

Environment.SetEnvironmentVariable: we recommend that the length of value be less than 2048 characters #12914

Description

@amelvil2-ford

Type of issue

Other (describe below)

Description

From https://learn.microsoft.com/en-us/dotnet/api/system.environment.setenvironmentvariable?view=net-10.0#environmentvariabletargetmachine-and-environmentvariabletargetuser-on-windows-systems

If target is EnvironmentVariableTarget.User or EnvironmentVariableTarget.Machine, we recommend that the length of value be less than 2048 characters.

Is this recommendation still up to date?

Why does Microsoft recommend that the value be kept under 2048 characters? What happens if it's over that size?

I tested it (on Windows 11) and it seemed to work for me with a string that e.g. had over 3000 characters. Let me know if you can provide any more context on this, thanks.

Page URL

https://learn.microsoft.com/en-us/dotnet/api/system.environment.setenvironmentvariable?view=net-10.0#system-environment-setenvironmentvariable(system-string-system-string-system-environmentvariabletarget)

Content source URL

https://github.com/dotnet/dotnet-api-docs-temp/blob/live/xml/System/Environment.xml

Document Version Independent Id

f467cd93-8900-c309-f037-3b01b71d6c23

Platform Id

2269d3db-dc50-34d3-b839-217d243ef97f

Article author

@dotnet-bot

Metadata

Metadata

Assignees

No one assigned

    Labels

    untriagedNew issue has not been triaged by the area owner

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions