Code

How to Create a Symbolic Link in Windows Vista

On my Linux server, I use symbolic links all the time to make shortcuts for myself. I recently istalled XAMPP on my Windows Vista machine and wanted to use a shortcut so that I could access my PHP scripts from my browser. I figured out how to, but from several different sources, so I thought I would consolidate. Here are the steps:

  1. Click the Start Button.
  2. Type cmd in the search box at the bottom.
  3. Press the Ctrl + Shift + Enter keys all at once.

    Note: This opens up the command prompt as Administrator. If you don't do this, you'll get a error saying that there are insufficient permissions to create the symbolic link later on.
  4. A box saying "Windows needs your permission to continue" will pop up. Click Continue.
  5. Go to the directory you want to create the link in. For example:
    cd c:/xampp/htdocs/
  6. Use mklink to create your symbolic link (or shortcut):
    mklink /D symfolder "c:\Users\username\Documents\My Folder\"
    Note: The /D is there because, in this example, we are linking to a directory. symfolder is the name of our symbolic link, you can change that to whatever you want. And, we have quotes around the target because there is a space in the name of it – if there's a space, you have to use the quotes, otherwise you'll get an error. To see more info about mklink, simply type mklink into the command prompt and then press Enter. A help dialogue will appear.

That's it! Your symbolic link has now been created.

If you were doing this in order to run a PHP script locally, here's how... Let's assume that your filename was c:\Users\username\Documents\My Folder\hello-world.php for this example. All you have to do is open up your browser and type http://localhost/symfolder/hello-world.php into the navigation bar. XAMPP is looking for files in the c:/xampp/htdocs/ folder and you told your system that symfolder should actually point to My Folder, so the hello-world.php script is found.



0 Comments

Be the first to leave a comment.

Leave a Comment

Name
Email
Website
Comment
Name and email are required. Your email will not be published.

This post was published on April 22nd, 2011 by Robert James Reese in the following categories: Command Prompt, PHP, Windows, XAMPP.

Before using any of the code or other content in this post, you must read and agree to our Terms & Conditions.

Copyright © 2014, Ink Plant. All rights reserved.