PowerShell cannot run Exes from long path


  1. Posts : 745
    Windows 10/11
       #1

    PowerShell cannot run Exes from long path


    First things first. Yes, LongPathsEnabled is set to 1 (enabled).

    Opening a PowerShell window in a deep path (>260 characters) and attempting to execute an Exe, such as "whoami", results in an error:
    PowerShell cannot run Exes from long path-1.png

    Cmd has no such issue (and note that Cmd automatically changes the path to 8.3 format):
    PowerShell cannot run Exes from long path-2.png

    Changing the PowerShell prompt to 8.3 does not fix the problem:
    PowerShell cannot run Exes from long path-3.png

    Based on what I read at the following link, this is a known and open issue with PowerShell:
    Incorrect behavior running executable if current location path is longer than 256 characters . Issue #13955 . PowerShell/PowerShell . GitHub

    I was just wondering if anyone here has come up with any workaround.
      My Computer


  2. Posts : 776
    Windows 7
       #2

    Prolly not what you're looking for

    PowerShell cannot run Exes from long path-image.png
      My Computer


  3. Posts : 745
    Windows 10/11
    Thread Starter
       #3

    @garlin Yeah, I was looking more for a way to get PowerShell into an 8.3 mode, so the Exe will run like it does in Cmd, but I suspect that Push Pop is the only workaround for now.
      My Computer


  4. Posts : 776
    Windows 7
       #4

    I tried several ideas to subvert PS, including:
    - Start-Process whoami -UseNewEnvironment
    - hacking $PWD or $CWD before invoking the command
    - switching my path to use UNC notation

    Nope. Nope. Nope.

    If I were to guess, starting in "C:\Windows\System32" and running downstream commands to tackle long pathnames would work. But something's broken about the exec() thread's inherited environment.
      My Computer


  5. Posts : 745
    Windows 10/11
    Thread Starter
       #5

    @garlin Thanks for checking! I wonder what Microsoft is telling their customers when they encounter this problem. Could it be: "We have this other cutting edge tool that works. It's called Cmd."
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 11:52.
Find Us




Windows 10 Forums