Wednesday, November 15, 2023

make a symbolic link in windows OS

 

Using Command Prompt (CMD) or PowerShell:

  1. Open Command Prompt or PowerShell as Administrator:

    • For Command Prompt, right-click on the Start button, select "Command Prompt (Admin)."
    • For PowerShell, right-click on the Start button, select "Windows PowerShell (Admin)."
  2. Navigate to the directory where you want to create the symlink:

    bash
    cd path\to\directory
  3. Create the symlink:

    • For a file:
      bash
      mklink linkname filepath
    • For a directory:
      bash
      mklink /D linkname targetdirectory

    Replace linkname with the desired name for the symlink and replace filepath or targetdirectory with the path to the file or directory you want to link.

    Example for a file:

    bash
    mklink mylink.txt C:\path\to\myfile.txt

    Example for a directory:

    bash
    mklink /D mylinkfolder C:\path\to\myfolder
  4. Press Enter.

No comments: