PowerShell에서 홈 디렉토리로 변경


15

cmd 명령 프롬프트 에서이 명령은 내 홈 디렉토리로 이동합니다.

cd %UserProfile%

PowerShell 명령 프롬프트에서 동일한 명령으로이 오류가 발생합니다.

Set-Location : Cannot find path 'C:\%UserProfile%' because it does not exist.
At line:1 char:3
+ cd <<<<  %UserProfile%
    + CategoryInfo          : ObjectNotFound: (C:\%UserProfile%:String) [Set-Location], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SetLocationCommand

PowerShell에서 동등한 명령은 무엇입니까?

답변:


28

이 명령을 사용하여 홈 디렉토리로 이동할 수 있습니다.

cd $home

5
이 답변의 추가 기능으로 % UserProfile %은 문자 그대로 $ home으로 변환되지 않으며 대신 $ env : UserProfile 변수를 사용해야합니다.
철자 D

11

이 속기는 내가 가장 좋아하는 것 중 하나입니다.

cd ~

당신은 또한 할 수 있습니다 :

cd ~\Deskt 

( Tab자동 완성 키를 사용하면 깊은 디렉토리에 묻혀 데스크탑이나 $ HOME의 다른 곳에 복사해야 할 때 잘 작동합니다)


좋아, 어떻게 든 ~PowerShell에서 사용할 수 있는지 몰랐습니다 !
Nate Barbettini
당사 사이트를 사용함과 동시에 당사의 쿠키 정책개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.