Home » Questions » Computers [ Ask a new question ]

Can I create a shortcut to a Windows directory?

Can I create a shortcut to a Windows directory?

I would like a quick command line-based way to get to a directory I use all the time. Is there a way to create some kind of alias in Windows so that I can type, for example, VS08P at a command prompt or in the address bar and Windows will automatically open the folder I want, which is c:\Documents and Settings\[My ID]\My Documents\Visual Studio 2008\Projects?

Asked by: Guest | Views: 171
Total answers/comments: 5
Guest [Entry]

"If you want to open that folder in Windows Explorer, you can either:

Create a shortcut (.lnk file) to a folder (by right clicking > New > Shortcut in Windows Explorer or on your desktop) then drop that shortcut somewhere in your path.
Create a batch file like this:

cd ""c:\Documents and Settings\etc\etc""
start .

then save it as VS08P.bat and put it somewhere in your path.

If you want to jump to it in your command prompt, see Phoshi's answer."
Guest [Entry]

"I will add to the 'create a simple batch' cacophony, with a twist. You can create a simple batch, but put a switch in side, such that you can use it to navigate to variety of favorite dirs:

@echo off
GOTO %1
:VS08P
cd c:\Documents and Settings\[My ID]\My Documents\Visual Studio 2008\Projects
GOTO END
:music
cd ""C:\Documents and Settings\[My ID]\My Documents\My Music""
GOTO END
:downloads
cd C:\shared\downloads
GOTO END
:logs
cd C:\[project path]\logs
GOTO END
:END

You can call it go.bat, and you can use it for all your favorite locations Your friends will think you are really cool because you can just type go logs on the commandline and you are magically taken to your logs directory.
You will still need to append the dir within which this bat is saved to your PATH."
Guest [Entry]

"set myDir=C:\Windows
cd %MyDir%

This works in the current command-line.

To make this static set an environment variable under ""Start->Settings->Controls->System->Advanced->Environment variables""

Set a Name and a Path (e.g. mypermaDir - C:\Windows)

Now, you can use this new variable:

cd %mypermaDir%"
Guest [Entry]

"How about this simple command line to be placed in a batch file :

%windir%\explorer.exe %userprofile%\My Documents\Visual Studio 2008\Projects

Using environment variables is a good way to have a portable code."
Guest [Entry]

"how about a one-line batch file (to be placed in the standard or customized ""Environment Variables"" :

explorer.exe ""c:\Documents and Settings[My ID]\My Documents\Visual Studio 2008\Projects""

various switches you can use too after explorer.exe

/e - no tree pane

/n - use new Explorer window"