8

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.)

12 Answers 12

9

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.

4
  • I was beat to the punch. This is the right answer.
    – th3dude
    Sep 2, 2009 at 13:11
  • Simple and completely flexible. Thanks a lot.
    – jmgant
    Sep 2, 2009 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, 2013 at 2:58
  • to create a shortcut you can just copy and then right click > paste short cut
    – phuclv
    May 19, 2018 at 7:54
8

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.

6

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.

0
4

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.

2
  • 1
    Oh, I didn't see and open the folder - yeah, you want "start ." for that.
    – Phoshi
    Sep 2, 2009 at 13:14
  • this is great. I have created bunch of .bat files for my angular projects such as "goto-myproject1.bat" and when I run cmd, I just type goto-myproject1 and tada.. Thanks
    – curiousBoy
    May 19, 2018 at 7:14
4

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.

1
  • 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, 2009 at 13:25
2
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%
1

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.

1
  • You're missing quotation marks.
    – Joey
    Sep 2, 2009 at 22:42
0

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

0
  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

0
  1. Create a file something.bat in directory where you cmd opens (C:\Users\Name) and write in:
@echo on
cd C:\your\link
cls

Reopen console and just call 'something'.

0

This is how I do it and I find it very useful.

  • Create a new txt file and write the following code into it.
    @ECHO OFF cd C:\YourProjectPath\FolderPath\
  • save as .bat file with a convenient name. (I usually save it as "goto-myProjectName.bat"

  • Then copy that bat file into your default path (when you run the cmd, whatever is your default path, it starts with that. For instance, on my machine it is windows/system32)

  • Then type your bat file's name without its extension.
  • For instance:goto-myProjectName

Then it should take you to there.

-1

I didn't like the batch file. Seems like over complicated.

I created a shortcut to a file in the directory that I want. Then I edited the properties to remove the file, leaving only the directory path.

Works like a charm. Now, just rename the short cut and your done.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .