Skip to content

PowerShell occupies the directory from which it is launched, preventing it from being deleted on Windows #27359

@YexuanXiao

Description

@YexuanXiao

Prerequisites

Steps to reproduce

Start cmd in path A, switch cmd to path B, run pwsh, then switch pwsh back to path A. At this point, the directory pointed to by path B cannot be deleted.

Expected behavior

PowerShell should not lock the startup directory, or at least unlock the original directory after changing to another path with cd.

Actual behavior

The startup directory cannot be deleted.

Environment data

Name                           Value
----                           -----
PSVersion                      7.6.1
PSEdition                      Core
GitCommitId                    7.6.1
OS                             Microsoft Windows 10.0.26300
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.4
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs-TriageThe issue is new and needs to be triaged by a work group.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions