41

I just installed Windows 7 Pro, and I'm configuring it to my preferences. I go to set up a symbolic link (since it supports symlinks).

But I don't seem to have the mklink program in C:\Windows\system32.

In administrator mode in Powershell:

PS C:\> mklink
The term 'mklink' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spel
ling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:7
+ mklink <<<<
    + CategoryInfo          : ObjectNotFound: (mklink:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
  • I can't find that file under %WINDIR% either, but running mklink on my side just works. I guess it's a built in system command. Does it say mklink is not a recognized command or something? – kizzx2 Jan 20 '10 at 18:20
  • A similar question was asked over at SO. See stackoverflow.com/questions/894430/… for more information and workarounds. – Kez Jan 20 '10 at 18:59
  • @kez: Hunh...didn't think SO was the best place to ask this. ::shrug:: – Paul Nathan Jan 20 '10 at 20:32
  • PowerShell will give this error, but Command Prompt works. – Rosdi Oct 10 '18 at 5:25
59

mklink is not a standalone tool – it is a built-in command in the Cmd.exe interpreter. The only way to run it externally is through cmd /c (similar to sh -c on Linux):

cmd /c mklink arguments

However, PowerShell itself supports creating various link types using the New-Item cmdlet, although it is not a full replacement (as it does not support creating relative symlinks).

New-Item -ItemType SymbolicLink|Junction|HardLink -Name Foo -Target Bar
| improve this answer | |
15

The solution is that mklink is a builtin on cmd.exe. Powershell therefore cannot directly access it.

Negative kudos to whoever thought that one up.

| improve this answer | |
8

PowerShell is not a complete replacement for CMD. Many CMD functions do not work in PS. Switch to CMD to run mklink

| improve this answer | |
  • Yeah, I hear you. Pretty frustrating though. – Paul Nathan Jan 20 '10 at 18:56

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