Tuesday, May 25, 2010

HowTo Create SymLink in Windows

SkyHi @ Tuesday, May 25, 2010

symlink windowsSymlinks let you define soft/hard links to files/directories placed in different locations. Essentially, they are like windows shortcuts (a.k.a. soft symlinks) and the other type is something in-between the two: shortcuts and Original Files/directories. You can use HardLinks as an original file/folder, transparently.


Linux/Unix has inbuilt feature of creating symlinks using “ln” command. On older Windows versions, there is no inbuilt utility that does that. However, on Windows Vista, Windows 7 you can use a command line utility called “mklink”. But not everyone likes the command line that’s why there is a GUI-based tool for this: Symlinker.


symlink windows


There are several Use cases for employing Hard symlinks. e.g. when you are running out of diskspace on your c:\ drive and certain programs still force you to install new software in c:\ drive (most microsoft, Google products do that) you can create a directory symlink and point it to another drive, save the buck. Another reason would be to move the caches, libraries (media player, iTunes songs lib), indexes (picasa photocache, search indexes, google desktop indexes) which take a large amount of disk space on your C:\drive.


There could be n number of other reasons, and this tool always comes handy.


Download Symlinker


NOTE: go to Control Panel, Turn Windows Features on o off to Install .Net Framework 3.5
http://code.google.com/p/symlinker/

To use this properly, here is some background on types of SymLinks:


Soft Link

A soft link is essentially a shortcut to a file or folder –it won’t pretend its part of the filesystem. You can still directly reference or open a file with the symlinked path, and it mostly works.


Hard Link

A hard link directly points to the file, and acts to the operating system as if it is the file itself. You’ll want to use this option the majority of the time if you are trying to fake an application’s directory just like the case described earlier.


Using Symlinks for a Network Share


You can even use Hardlinks/softlinks for pointing to Network shares thereby giving you a Mounted drive.



Deleting Symlinks


There’s nothing special you need to do here. Just delete the symlink file like you do.

We write about Tech Guides, Open Source, Programming, Web, Apple, iPhone,Android and latest in Tech@taranfx on Twitter or by subscribing below:

==================================================================================

Using Symlinks in Windows Vista




One of the long-awaited features in Windows Vista was the ability to use symbolic links, the way you can in linux. Sadly, they don’t work quite as well as they could, but it’s a big upgrade from prior versions, and has solved a number of problems for me already.


Using the mklink Command


The command that you need to use is mklink, which you’ll use from the command line. Just type it on the command line to see the options:


C:\Users\geek>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.


For instance, if you wanted to make the folder C:\Users\Geek\TestFolder available from C:\TestFolder as well, you could use the following command.



C:\mklink /D C:\TestFolder C:\Users\Geek\TestFolder
symbolic link created for C:\TestFolder <<===>> C:\Users\Geek\TestFolder



Now if you look in C:\TestFolder directory, you’ll see whatever files were in the other directory.


Understanding the Options.


MKLINK link target


Using the command without any extra options creates a soft link to a file.


/D creates a symbolic link, or a soft link.


This essentially acts like a shortcut to a folder in prior versions of Windows, except you don’t have to use an actual shortcut.


/H creates a hard link, which points directly to the file.


This option can’t be used for folders directly for some reason, you’ll have to use the next option.


/J creates a “Directory Junction”


A Directory Junction is actually just a hard link to a directory. This is a feature that existed prior to Vista as well. If you are trying to symlink to a directory using a hard link, then you should use this option.


Understanding Hard vs Soft Links


Hard Link


A hard link directly points to the file, and acts to the operating system as if it is the file itself. You’ll want to use this option the majority of the time if you are trying to fake an application’s directory.


Soft Link


A soft link is essentially a shortcut to a file or folder – if you are using Windows explorer, you’ll be redirected to the directory if you double-click on a shortcut, it won’t pretend its part of the filesystem. You can still directly reference or open a file with the symlinked path, and it mostly works.


Using Symlinks from a Network Share


One of the things that’s been extensively discussed is that you cannot use the Vista symlinks from another operating system (not surprising), but you cannot use them from a network share either. This is troublesome if you expect to use this feature on a web server or a file server.


Deleting Symlinks


To delete a symlink, you can just delete the link. Just make sure you don’t delete the original file.


REFERENCES
http://www.taranfx.com/create-symlink-in-windows
http://www.howtogeek.com/howto/windows-vista/using-symlinks-in-windows-vista/