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?

  • doskey macros can override built-in commands - do those do what you're looking for? – Ben N Aug 11 '19 at 20:23
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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