13

When I shift-right-click on a folder I had been able to "open command window here".

NOTE: I am NOT INTERESTED in the registry hack to put this feature back on.

After which I could use mklink to create symbolic links.

Under recent profound wisdom of Microsoft, after last couple of Windows 10 updates, "command window here" has been replaced with "powershell here".

Hence complying with Microsoft's esteemed wisdom implying that I should use powershell instead of the long outdated cmd

  • what is the equivalent of making a softlink in powershell?
  • and any other type of link that mklink could make?
Blessed Geek
  • 21,058
  • 23
  • 106
  • 176
  • I think this is off-topic for this site, but you can go into the address bar for a folder and type `cmd` to get a command shell there. From PowerShell you can do `cmd /c mklink`. There is no command currently included in PowerShell that does this, to my knowledge. – briantist May 23 '18 at 00:22
  • 3
    Possible duplicate of [Creating hard and soft links using PowerShell](https://stackoverflow.com/questions/894430/creating-hard-and-soft-links-using-powershell) – Kory Gill May 23 '18 at 01:02
  • 1
    Win10/PS5 supports this with New-Item – Kory Gill May 23 '18 at 01:03
  • 2
    `new-item` can create HardLink, SymbolicLink, and Junction link types. However, unlike CMD's `mklink`, it can't create a SymbolicLink or Junction to a non-existent target. It used to support creating a plain symbolic link (i.e. not a directory symbolic link) to a non-existent target, but that's not working in the latest release of Windows 10. Maybe it was causing too much confusion with people expecting Windows symbolic links to function like Unix symlinks. – Eryk Sun May 23 '18 at 02:43
  • 2
    Also, `remove-item` can't remove a directory symbolic link in PowerShell 5.1. You have to use the more verbose command `[IO.Directory]::Delete('symlink_path')`. `remove-item` works to delete a junction, but it requires `-force` and displays a warning as if it's going to delete the contents of the target directory, when it actually doesn't (at least not in 5.1). I'm surprised they released code in such an unfinished state. – Eryk Sun May 23 '18 at 16:55
  • https://superuser.com/questions/98420/mklink-not-installed-on-windows-7 – Al Fahad Jul 12 '20 at 16:16

2 Answers2

14

This is answered in [1]: https://stackoverflow.com/a/34905638/4744055

But use New-Item Powershell command. No DOS CMD necessary any more.

   New-Item -Path <to> -ItemType SymbolicLink -Value <from>

where <to> is the location to put the new symlink, and <from> is the target of the new symlink. E.g.

   New-Item -Path "$env:USERPROFILE\desktop\MyNewLinkToCmd.exe" `
            -ItemType SymbolicLink -Value "c:\windows\system32\cmd.exe"

Also note that you must run this from Powershell running as administrator.

Ross Presser
  • 6,027
  • 1
  • 34
  • 66
Manabu Tokunaga
  • 956
  • 10
  • 19
  • 1
    For a relative directory symlink, make sure to prefix the from path with .\ or you will end up with a broken file symlink. Others also pointed out that you may need a somewhat new PowerShell version (at least pwsh 7.1.x) for this to work. – CodeManX Oct 12 '22 at 21:51
  • 1
    Due to a still-not-fixed bug from 2018, it is actually necessary to use `mklink` in some cases; see https://github.com/PowerShell/PowerShell/issues/6232 – sam-6174 Jun 05 '23 at 00:49
11

You can create soft links in PowerShell via:

cmd /c mklink /J "<link>" "<target>"

The above uses old cmd in PowerShell. However, the above does not work for symbolic links (/D).

codewario
  • 19,553
  • 20
  • 90
  • 159
Lidia
  • 2,005
  • 5
  • 25
  • 32
  • 1
    Just wanted to point out the quotes in this can cause problems when copying and pasting. Use " instead of “ or ”. – Adam Dylla Apr 26 '21 at 17:22