5

I've recently changed from Ubuntu to Windows 7. One feature I'm struggling to develop without, is symbolic links. In linux, I would simply

ln -s /where/to/ /where/from/

I've done some googling for Windows 7, but don't know what the standard accepted method is.

BTW I tried "MLINK" in the command line, and it said MLINK not found... - EDIT: As Hello71 pointed out, it is MKLINK, I misread it. Thanks!

EDIT: I want to be able to include a php framework in this manner, as each of my projects all use the same library.

Dean Rather
  • 2,657
  • 9
  • 32
  • 41

3 Answers3

6

There's a typo in your command; It's mklink, not mlink. I still recommend using Junction, mainly because it also allows for deleting junction points, unlike mklink.

Hello71
  • 8,397
  • 5
  • 40
  • 44
  • ... does this not work with PHP include()'s or something...? I'm having a little trouble... – Dean Rather Jul 19 '10 at 16:47
  • mklink worked whereas junction did not. – Dean Rather Jul 19 '10 at 17:13
  • mklink didn't work properly either... it allowed me access to the files in the directory, but not files in subdirectories. I tried mklinnk with the /d, /j, and /h params. with junction, I could paste the filepath into notepad and it would open, but with php's file_get_contents() it would not open. – Dean Rather Jul 19 '10 at 18:08
  • Are you sure that Apache has permissions to access the target directories and files? – Hello71 Jul 19 '10 at 18:14
0

In Windows 7 SP1, MKLINK.EXE can create a symbolic link to either a directory or a file. But it can also create a JUNCTION link to a directory.

The ordinary DEL command (or any of the delete options in the Windows Explorer GUI) can remove any of these links, safely (i.e. without deleting the target file or directory - unless it's an empty directory).

The syntax is straightforward. Here is an example batch (.bat) file -

::  ** Location of target Directory **
SET DirPath=C:\TEST

::  ** Create Symbolic Link in Current Directory **
MKLINK /D  SymLinkName  "%DirPath%"

::  ** Create Junction in Current Directory **
MKLINK /J  JunctionName "%DirPath%"
Ed999
  • 242
  • 2
  • 12
  • Very funny - DEL *will* delete all the files especially non-empty directories w/o putting it into trash. Use rmdir instead. Thanks for nothing. Never trust anybody and especially not Windows OS. – Jens Jul 15 '22 at 10:48
  • Except that I've extensively tested this answer on Windows 7, and the DEL command works as described in my original answer in 2017. Perhaps you are not running Windows 7. – Ed999 Jul 23 '22 at 03:40
-1

I've found a very simple method of creating a symbolic link to a directory on Windows 7.

  1. Open a folder containing target folder in explorer.
  2. Copy target folder to clipboard via context menu or Ctrl+C.
  3. Open Start Menu folder in explorer, you may just type shell:Start Menu in address bar.
  4. Click right mouse button on an empty space of the folder to open context menu and choose Paste shortcut.

That's it.

omegastripes
  • 381
  • 2
  • 7