How to create symbolic link in Windows explained with simple steps.

Creating symbolic links (symlinks) in Windows allows you to create file or directory references pointing to different locations. This is useful for redirecting paths, organizing data, or mimicking Unix-like environments.

Prerequisites

Administrator Privileges: You must run Command Prompt or PowerShell as Administrator.

Method 1: Using Command Prompt (mklink)

  1. Press `Windows Key`, type "cmd".
  2. Right-click "Command Prompt" and select "Run as administrator".
  3. Use the `mklink` command with appropriate syntax:

    Create a symbolic link to a File:

    How to create symbolic link in Windows explained with simple steps.

    mklink "C:PathTo*" "C:PathToTarget*"

    Create a symbolic link to a Directory (Junction):
    mklink /D "C:PathToLinkFolder" "C:PathToTargetFolder"

    Create a Hard Link to a File (Different from symlink):
    mklink /H "C:PathTo*" "C:PathToTarget*"

    How to create symbolic link in Windows explained with simple steps.

    Create a Directory Junction:
    mklink /J "C:PathToJunction" "C:PathToTargetFolder"

  4. Press Enter. Success messages confirm link creation. Verify using `dir`.

Method 2: Using PowerShell (New-Item)

  1. Press `Windows Key`, type "PowerShell".
  2. Right-click "Windows PowerShell" and select "Run as administrator".
  3. Use the `New-Item` cmdlet:

    Create a symbolic link to a File:
    New-Item -ItemType SymbolicLink -Path "C:PathTo*" -Target "C:PathToTarget*"

    Create a symbolic link to a Directory:

    How to create symbolic link in Windows explained with simple steps.

    New-Item -ItemType SymbolicLink -Path "C:PathToLinkFolder" -Target "C:PathToTargetFolder" -Directory

    Create a Hard Link to a File:
    New-Item -ItemType HardLink -Path "C:PathTo*" -Target "C:PathToTarget*"

    Create a Junction Point (Directory):
    New-Item -ItemType Junction -Path "C:PathToJunction" -Value "C:PathToTargetFolder"

    How to create symbolic link in Windows explained with simple steps.
  4. Press Enter. No output indicates success. Verify using `Get-Item "C:PathToLink" Select-Object Target`.

Key Parameters Explained

  • Symbolic Link (File/Directory): Points to the target path. File Explorer treats directory symlinks like real folders. Requires NTFS.
  • Hard Link (File): Direct reference to the target file's data on disk. Deleting the original doesn't break the link until the last hard link is deleted.
  • Junction Point (Directory): Legacy directory symlink, primarily for backward compatibility. Less flexible than directory symlinks.

Troubleshooting

  • Access Denied: Ensure running as Administrator.
  • The system cannot find the path specified: Verify target path exists.
  • Cannot create a file when that file already exists: Delete or rename the existing file/folder at the link path.
  • Symbolic links may not work across different drives or network locations reliably.

Related News