gpt4 book ai didi

powershell - 将%username%变量与PowerShell Set-Location Commandlet一起使用

转载 作者:行者123 更新时间:2023-12-04 00:58:38 25 4
gpt4 key购买 nike

在Windows文件资源管理器中,我们可以使用C:\Users\%username%,但在PowerShell中不能使用Set-Location

有一条线可以解决的办法吗?

文件资源管理器-成功

设置位置-失败

$set-location -path "c:\users\%username%"
set-location : Cannot find path 'C:\users\%username%' because it does not exist.
At line:1 char:1
+ set-location -path "c:\users\%username%"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

最佳答案

# this will do
Set-Location -path "c:\users\$env:username\desktop"

# alternative syntax
cd "c:\users\$env:username\desktop"

关于powershell - 将%username%变量与PowerShell Set-Location Commandlet一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23851240/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com