Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

(Note that the question isn't about what to do with Visual Studio 2008. Unless the solution is a batch file, I think I've asked the question on the right site.)

share|improve this question

9 Answers 9

up vote 7 down vote accepted

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

  1. 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.
  2. 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.

share|improve this answer
    
I was beat to the punch. This is the right answer. –  th3dude Sep 2 '09 at 13:11
    
Simple and completely flexible. Thanks a lot. –  jmgant Sep 2 '09 at 13:29
    
You don't need to change directories and then start the current directory. Simply start the target directory in one go. –  Bob Jul 24 '13 at 2:58

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.

share|improve this answer
    
+1, great idea, thanks! –  jmgant Sep 2 '09 at 14:17

The solution is probably a batch file. Make a VS08P.bat in system32 (normally :\windows\system32) that contains:

@ECHO OFF
cd c:\Documents and Settings\[Your ID]\My Documents\Visual Studio 2008\Projects\

Then, typing VS08P should take you there.

share|improve this answer
1  
Oh, I didn't see and open the folder - yeah, you want "start ." for that. –  Phoshi Sep 2 '09 at 13:14

You could set a custom environment variable:

  • Right-click "My Computer" and select "Properties"
  • Select the tab "Advanced"
  • Click the button "Environment variables"
  • At the top part of the window you can define your own system variables

I have a German Windows installation so the names of the items mentioned above can be slightly different ;)

Another way would be:

Create a batch with the following content and run the shell through this:

@echo off
set VS08P = c:\Documents and Settings\[My ID]\My Documents\Visual Studio 2008\Projects
cls

This way you can add as many vars as you like and call them inside your shell session.

share|improve this answer
    
Thanks for the suggestion. I wondered if something like that would work. I can just type %VS08% and it takes me straight there. –  jmgant Sep 2 '09 at 13:25

Use the mklink command. From the command-line:

C:> mklink /D VS08P c:\Documents and Settings\[My ID]\My Documents\Visual Studio 2008\Projects

You will now have c:\VS08P that points to your Visual Studio directory above.

share|improve this answer
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%
share|improve this answer

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

share|improve this answer

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.

share|improve this answer
    
You're missing quotation marks. –  Joey Sep 2 '09 at 22:42
  1. make a shortcut file
  2. copy it into windows\system32\
  3. rename it to whatever you want to have to type to bring up the directory

(maybe "vsproj" if your directory is "C:\docs and set\user\my documents\visu studio\proj")

then when you hold the windows key and type r the run command appears type in "dir" and there ya have it!

maybe i'm a super user :) hahaha

i'm not sure if you meant specifically from the command prompt window i'm not sure if that'll work but this might help some people anyway! enjoy

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.