2

Say I want to navigate to a directory but don't want typing the directory every time.

Is there a way to define a customized short keys in the cmd prompt like

set root=C:\Users\sz\to\this\path

So next time only typing cd root can direct me to the target root. I hope the short key will be stored permanently - when I re-open the cmd prompt, the short key is still valid.

Even better, is it possible to define a short key that only typing root (without typing cd) can do the same thing?

Thanks in advance!

sozhen
  • 7,627
  • 14
  • 36
  • 53

1 Answers1

3
doskey root=cd /d "C:\Users\sz\to\this\path"

Note: the macro is gone, if you close your cmd-window

EDIT

another way is a batchfile somewhere in the path, for example root.bat as a "one-liner":

@cd /d "C:\Users\sz\to\this\path"
Stephan
  • 53,940
  • 10
  • 58
  • 91
  • Thanks for your answer - works like magic! But is there a way to store the macro somewhere for usage? That would be even more handy. – sozhen Apr 25 '14 at 21:01
  • 1
    sure there is. It can be stored in the registry somehow - but I'm not a specialist in that. This could help: http://stackoverflow.com/a/17405182/2152082 – Stephan Apr 25 '14 at 21:42