Share via

MKLINK not recognized

Anonymous
2018-09-13T18:08:20+00:00

I want to use MKLINK (in Powershell) to sync a folder to OneDrive.

There are many articles about using this is Windows 10.

But I get this message from Powershell:

mklink : The term 'mklink' is not recognized as the name of a cmdlet, function, script file, or operable program.

Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

How do I get access to MKLINK?

Windows for home | Windows 10 | Files, folders, and storage

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
Answer accepted by question author
  1. Anonymous
    2018-09-13T19:13:01+00:00

    Mklink is not a standalone executabe, it's built-in to the Command Prompt (cmd.exe). It can't run directly from PowerShell.

    So easiest thing to do is open an actual Command Prompt, type 'mklink' and you'll get the built-in help.

    Keith

    90+ people found this answer helpful.
    0 comments No comments
Answer accepted by question author
  1. Anonymous
    2018-09-13T19:39:08+00:00

    If you really want to launch from PowerShell, as part of a script, perhaps, you need to Use Start-Process. The docs actually contain a great example of launching a Command Prompt and executing the 'dir' command (except /c parameter should be changed to /k like so:

    PS C:> Start-Process -FilePath "$env:comspec" -ArgumentList "/k","dir",""%systemdrive%\program files""

    So you would use some like:

     Start-Process -FilePath "$env:comspec" -ArgumentList "/k", "mklink", "/j", ""<Link Path>"",""<Target Path>""

    Keith

    40+ people found this answer helpful.
    0 comments No comments
Answer accepted by question author
  1. Anonymous
    2018-09-14T16:58:38+00:00

    You're welcome. Things can be simplified somewhat by using the built-in PowerShell commands to create Symbolic Links:

    https://docs.microsoft.com/en-us/powershell/wmf/5.0/feedback_symbolic

    Please mark one or more of my replies as 'Answer' to help others who happen across this thread.

    Keith

    7 people found this answer helpful.
    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Anonymous
    2018-09-13T18:16:59+00:00

    Hi, MDougC

    Check these links, I hope it helps.

    https://www.computerhope.com/mklink.htm

    https://superuser.com/questions/1020821/how-to-...

    https://www.howtogeek.com/howto/16226/complete-...

    Note: This is a non-Microsoft website. The page appears to be providing accurate, safe information. Watch out for ads on the site that may advertise products frequently classified as a PUP (Potentially Unwanted Products). Thoroughly research any product advertised on the site before you decide to download and install it.

    1 person found this answer helpful.
    0 comments No comments
  2. Anonymous
    2018-09-14T16:45:35+00:00

    Thank you, Keith.  You have taught me something new.

    It seems that Microsoft would provide a better way to sync folder to OneDrive (other than the built-ins).

    0 comments No comments