While testing something earlier I needed to create a symbolic link on my laptop which is running Windows 7 Ultimate 64-bit. I first was going to use cygwin to create the symbolic link with ln however cygwin complained about it which is noted below in more detail. After receiving the error from cygwin I decided to look at the possible Windows commands and located mklink which is described in more detail below and will easily allow you to create symbolic links on a Windows 7 computer.
Cygwin Error Creating Symbolic Link On Windows 7:
- C:\Program Files>ln -s SOME-APP "C:\Program Files (x86)\SOME-APP"
- cygwin warning:
- MS-DOS style path detected: C:\Program Files (x86)\SOME-APP
- Preferred POSIX equivalent is: /cygdrive/c/Program Files (x86)/SOME-APP
- CYGWIN environment variable option "nodosfilewarning" turns off this warning.
- Consult the user's guide for more details about POSIX paths:
- ln: failed to create symbolic link `C:\\Program Files (x86)\\SOME-APP/SOME-APP': File exists
- C:\Program Files>
As you can see above I could have worked around the issue but the best policy would be to use a Windows command which happens to be mklink.
Use mklink To Create Symbolic Links In Windows:
The mklink command will allow you to create symbolic as hard links within Windows 7 as noted in the mklink help information below.
- C:\>help mklink
- Creates a symbolic link.
- MKLINK [[/D] | [/H] | [/J]] Link Target
- /D Creates a directory symbolic link. Default is a file
- symbolic link.
- /H Creates a hard link instead of a symbolic link.
- /J Creates a Directory Junction.
- Link specifies the new symbolic link name.
- Target specifies the path (relative or absolute) that the new link
- refers to.
Example mklink Command On Windows 7 Ultimate 64-bit OS:
- C:\Program Files>mklink /D SOME-APP "C:\Program Files (x86)\SOME-APP"
- symbolic link created for SOME-APP <<===>> C:\Program Files (x86)\SOME-APP
- C:\Program Files>
Now when you open “C:\Program Files\SOME-APP” you will see all of the files within the “C:\Program Files (x86)\SOME-APP”. The /D specifies a symbolic link while /H specifies a hard link.