Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've created a symbolic link like so:

PS C:\dev\bin> cmd /c mklink "wd" c:\dev\code
symbolic link created for wd <<===>> c:\dev\code

OK, simple. So then I try to cd to it:

PS C:\dev\bin> cd wd
Set-Location : Cannot find path 'wd' because it does not exist.

PS C:\dev\bin> cd .\wd
Set-Location : Cannot find path '.\wd' because it does not exist.

PS C:\dev\bin> cd \wd
Set-Location : Cannot find path 'C:\wd' because it does not exist.

It is soooo much easier to do this in Linux. How do I actually cd to a symlink in PowerShell?

(It seems like a simple question, but the first 3 pages of google results didn't have an answer.)

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

The correct command to link a directory is

cmd /c mklink /D link target

Check out 'mklink /?' for other options.

share|improve this answer
1  
That did it. So what on earth did I create when I did it without the /D? You'd think that would have errored, since c:\dev\code is not a file. –  jcollum Apr 9 '12 at 19:21
add comment

I recommend using the PowerShell Comuunity Extensions. It adds the commands New-Symlink, New-Junction, New-Hardlink, and Get-ReparsePoint. It also adds some aliases for things like ln so you can just use the Linux syntax.

share|improve this answer
    
Huh?? cmd /c mklink is the command to make the symlink. Or did you miss that this is in Powershell? –  jcollum Apr 9 '12 at 18:49
    
cmd /c should not change the working directory unless specifically asked to. It is required here because mklink is a cmd builtin. –  grawity Apr 9 '12 at 18:52
    
Sorry, I did miss that, I have revised my answer. This is what I use. –  Scott Chamberlain Apr 9 '12 at 19:04
    
Just to clarify, 'cmd' is not part of powershell, that is the reg windows shell, although hopefully down the road we get more robust symlink capability in powershell, or any capability for that matter, b/c right now there is none! –  BigHomie Jan 17 '13 at 16:19
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.