Replacing dir with to custom utility in Windows 7

2

I'm using Windows 7 and would like to change the default dir command in the Command Prompt to another program.

I've tried putting both dir.exe and dir.bat in the C:\ root but when I type dir it doesn't launch the program. Does anyone know to launch it after I type dir? It might be a registry change.

Thanks in advance.

DJQuad

Posted 2018-02-07T20:34:53.320

Reputation: 21

Read over this post as well in case you are looking for something like a command line alias in Windows https://stackoverflow.com/questions/20530996/aliases-in-windows-command-prompt .... there are several answers here that may suffice for your needs.

– Pimp Juice IT – 2018-02-08T13:21:04.397

Try to put it in C:\Windows, because it is in the %path% variable. – iTechieGamer – 2018-03-08T08:52:38.313

Answers

1

I would like to change the default dir command in the Command Prompt to another program.

You can't, at least not directly, as dir is built in tocmd.exe:

Internal commands

The Windows CMD shell CMD.exe contains a number of 'internal' commands, additional 'external' commands are also supplied as separate executable files. External commands are generally stored in the C:\WINDOWS\System32 folder, this folder is part of the system PATH .

This arrangement means that both internal and external commands are always available no matter what your current directory happens to be.

ASSOC, BREAK, CALL ,CD/CHDIR, CLS, COLOR, COPY, DATE, DEL, DIR, DPATH, ECHO, ENDLOCAL, ERASE, EXIT, FOR, FTYPE, GOTO, IF, KEYS, MD/MKDIR, MKLINK (vista and above), MOVE, PATH, PAUSE, POPD, PROMPT, PUSHD, REM, REN/RENAME, RD/RMDIR, SET, SETLOCAL, SHIFT, START, TIME, TITLE, TYPE, VER, VERIFY, VOL

However ...

It is possible for a system to have an internal command and an external command with the same name. If you have a command called DATE.exe and want to run that in preference to the internal DATE command, use the full pathname to the file e.g. C:\utils\date.exe even if your current directory is C:\utils\

Source Internal commands - Windows CMD - SS64.com

So instead of using just dir you have to use the full name of your replacement, in your case:

c:\dir.exe

Further Reading

DavidPostill

Posted 2018-02-07T20:34:53.320

Reputation: 118 938

1I usually rename it to something similar and put it in a location that is in the path environment. For example, the linux command ls is not present in cmd, so you could name it ls.exe and place it in c:\windows\system32 and now you can use ls to perform the dir. – LPChip – 2018-02-07T21:02:20.690