Powershell breaks with semicolons in the PATH environment variable

Anonymous
2025-01-20T23:04:48+00:00

I've been going down a rabbit hole with how Powershell processes the PATH environment variable. I am developing a program that helps manage the PATH, and I recently discovered that it has issues when a path containing semicolons is added to the PATH.

According to this comment on Github](https://github.com/HorridModz/Flow.Launcher.Plugin.Add2Path/pull/8#issuecomment-2596593503%29 "github.com") by another user, Powershell interprets the PATH by splitting using the delimiter, which is a semicolon. However, it interprets quotes literally.

This is a problem, because adding a folder path that contains a semicolon PATH using Windows' environment variable editor  (Edit the system environment variables -> Path -> Edit) causes Windows to automatically wrap the required paths in quotes, breaking Powershell.

For example, the PATH value C:\Program Files (x86);"C:\;My Folder";C:\Program Files is wrongly interpreted like this, since Powershell naively splits by semicolons:

C:\Program Files (x86) "C:\ My Folder" C:\Program Files  

This behavior only occurs in Powershell, not Command Prompt. Here's a video demonstrating it: https://www.mediafire.com/file/aih2ky9fz07x5w0/powershellpathwithsemicolonsbug.mp4/file

Is this behavior a bug, or is it intentional? And is there any workaround?

***moved from Windows / Windows 10 / Files, folders, and storage***

Windows Server Remote and virtual desktops PowerShell

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question. To protect privacy, user profiles for migrated questions are anonymized.

0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Anonymous
    2025-02-04T08:25:52+00:00

    Hi,

    This seems to be a PowerShell issue. I can reproduce this on both Windows PowerShell 5.1 and PowerShell 7. It is recommended to report this problem to Microsoft with the Feedback Hub App.

    Send feedback to Microsoft with the Feedback Hub app - Microsoft Support

    0 comments No comments