Accueil > INFORMATIQUE > Symbolic links in Windows

Symbolic links in Windows

samedi 17 septembre 2005, par thierrybo

Toutes les versions de cet article : [English ] [français ]

Symbolic links using Windows XP is something few people are aware.


I have to admit it, I was personally not aware of this fact myself. I believed that Symlinks was only a feature available only on Unix systems until I discover this entry on Lowerbounds, Upperbounds site, Sysinternals Junction.

But symbolic links for what ? Personally I have three good reasons :

- I remember many times where I was upset because the program or web application I was using ask me to select a file on my computer. Oh well, I put a windows shortcut on my desktop so that I can open easily this very very deep folder on my hard disk. Unfortunately the program want to download the shortcut file instead, damn !

- I use a lot of old dos games, and some of them do not run if the drive letter where they are installed is not C :. I use another drive for programs, say D :\dosgames\ for old dos games. With symbolic links I can create a symbolic c :\dosgames\ folder that is linked to d :\dosgames\

- I have a WAMP test system and I use many Perl scripts. I am bored to always change the Shebang line from « # !/usr/bin/perl » to «  !#C :/programs/perl/perl.exe ». This IS the MAIN reason I want to use symlinks on Windows.

So NTFS supports symlinks, but there is no official support from Microsoft. Sysinternals offers for free a program named « junction.exe » . With this program you can create symlinks ONLY with FOLDERS, this does not work for files.
However, I found a command line utility named ... guess ...« hardlink.exe » on JCB site (in french) that creates symlinks for FILES ONLY.

My comments after using them some days :

  • « Jean-Claude Bellamy » warns on his site “The original file (or folder) and the symbolic link should be on the same logical drive ”. As far as I used them, I created symlinks on drive C linking to folders on drive D without any problem, or have I missed something ?
  • I noted that you can’t delete folders in a symbolic folder. Ie. you create a symbolinc link c :\folderA linking to real folder d :\folderB. Inside d :\folderB you have another folder, say d :\folderB\sub_folder1.
    If you open c :\folderA and try to delete c :\folderB\sub_folder1 you have a warning about the folder being in use. This does not happen with files.
  • If you deletes the symbolic link of a file, you only delete the symlink, not the file (this was not obvious to me).
  • If you delete the REAL file, then the symbolic link BECOMES the file.
  • About Apache and Shebang line. I remember that if you do not specify a drive letter, Apache tries the drive letter where Apache is installed, or the boot drive (do not remember exactly). So I tried to lure Apache with this :

I tried on both Apache drive and system drive, but unfortunately I only get a « 500 Internal Server Error ». Any help would be appreciated !

Répondre à cet article | RétroLiens :1

Répondre à cet article