Unable to move forward using cd

前端 未结 2 1666
生来不讨喜
生来不讨喜 2021-01-23 12:09

I\'m having a problem moving forward through a path with PowerShell. I am able to move up the directory but not down. Here\'s the situation:

I open PowerShell and type

2条回答
  •  无人及你
    2021-01-23 12:56

    Before PowerShell can execute your cd command, it needs to parse it, and PowerShell's parser interprets your command like this:

    cd  C:\Users\Robert Inspiron14
    \/  \_____________/ \________/
    Command Name  |            |
                 argument 1    |
                             argument 2
    

    In other words, C:\Users\Robert and Inspiron14 are interpreted as separate arguments.

    Neither argument is a path to a valid directory, so cd (or rather Set-Location for which cd is an alias) throws an error.

    You can force PowerShell to recognize C:\Users\Robert Inspiron14 as a single string argument by qualifying its boundaries using quotation marks (both " and ' will work):

    cd 'C:\Users\Robert Inspiron14'
    

    You can read more about how PowerShell parses command expressions in the about_Parsing help topic

提交回复
热议问题