1

In bash on Linux platforms, I can write an alias that performs a command, such as:

alias cdpics='cd /home/me/Pictures; ls -l'

Which will change to my Pictures folder and list its contents. And even use it to override commands:

alias sudo='echo;cd'

Which will make the sudo command echo what they pass to it, then change to their home holder. Is there a way to do this on the Windows command prompt - particularly the latter example? for instance, can I have the dir or tree command instead execute a batch file?

1
  • doskey macros can override built-in commands - do those do what you're looking for?
    – Ben N
    Aug 11, 2019 at 20:23

1 Answer 1

1

Can I have the dir or tree command instead execute a batch file?

You can use doskey for this:

doskey dir c:\batch\mydir.cmd
doeskey tree c:\batch\mytree.cmd

See Doskey - recall commands - Windows CMD - SS64.com

You must log in to answer this question.

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