如何获取提示的当前目录 [英] How do I get the current directory of the prompt
本文介绍了如何获取提示的当前目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在编写一个脚本,其中第一个参数是文件名.但是每当我尝试在需要文件的内容中使用该字符串时,我都会收到有关未找到该文件的错误.如何获取 powershell 提示所在的当前目录?出于某种原因,它不断返回我的用户配置文件目录:
I'm writing a script where the first parameter is a filename. But whenever I try to use that string in something that takes a file, I get an error about the file not being found. How do I get the current directory the powershell prompt is in? For some reason it keeps returning my user profile directory:
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
推荐答案
pwd
是您要搜索的 cmdlet ;)
pwd
is the cmdlet you search for ;)
这是 Get-Location
的别名.
这篇关于如何获取提示的当前目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文