【问题标题】:How do I get the current directory of the prompt如何获取提示的当前目录
【发布时间】:2015-07-31 20:48:11
【问题描述】:

我正在编写一个脚本,其中第一个参数是文件名。但是,每当我尝试在需要文件的内容中使用该字符串时,都会收到有关找不到文件的错误消息。如何获取 powershell 提示符所在的当前目录?出于某种原因,它不断返回我的用户配置文件目录:

C:\Users\user1> [System.IO.Directory]::GetCurrentDirectory()
C:\Users\user1

C:\Users\user1> cd\

C:\> cd temp

C:\temp> [System.IO.Directory]::GetCurrentDirectory()
C:\Users\user1

【问题讨论】:

    标签: powershell


    【解决方案1】:

    pwd 是您搜索的 cmdlet ;)

    这是Get-Location 的别名。

    【讨论】:

    • 您应该提到pwdGet-Location 的别名。
    • :D 我刚刚提交了一个编辑,而你写的。谢谢!!
    • 在你们俩写评论之前,我还编辑了我的答案;-)
    • 我们都太快了!!一旦我能接受答案,我会的。再次感谢!这让我发疯了..*海盗的声音*
    猜你喜欢
    • 2010-10-26
    • 2010-11-11
    • 1970-01-01
    • 2016-08-20
    • 2016-11-23
    • 2013-01-29
    • 2013-08-10
    • 2010-10-21
    相关资源
    最近更新 更多