how to replace del cmd with my own

Hi,

Is there a way to replace the windows del cmd with one's own.

I've been bitten too often in the past by the same issue and tonight was the last straw.

I had bunch of winrar volume files in a particular folder. This folder also contained a file with the extension .rar_xyz.

Whilst using TotalCommander it was convenient to just execute the dos cmd
[del *.rar] in the command line edit box of TotalCommander while in this folder.

My intent was only to delete the .rar files and not my main copy with extension .rar_xyz, however the del command also deleted the .rar_xyz file.

Since this issue has happened to me in the past I agressively created my own del.exe that addresses this issue and further more behaves exactly like the normal del cmd.

My issue is that this del.exe of mine does not get executed regardless of where I copy it - I copied it to System32 and even created a special folder which I added at the start of my path string enviromental variable.

It only runs if one executes del.exe *.rar

Is there any way I can overcome this?

Be sure that you are in working directory with your own del.exe and then execute .\del.exe *.rar or whatever.

This has nothing to do with C++ programming though. There is dedicated API to delete files and regular expressions libraries to overcome windows shell limitations like the one you said.
You'll find that del is a built in command, there isn't a seperate program for you to replace.
PowerShell is a lot better than CMD, and the good news is that you probably already have it.
Last edited on
Thank you the responses. I understand there are other options like powershell or could have even renamed my own executable to something like xdel.exe, but would then have to start disciplining myself to use these variants instead of windows versions.

I'm just scared that before the habbit of using something else becomes set, I may fall prey to the same type of issue again, and would have liked to completely avoid it by superceding windows del cmd with my own.

Also as mentioned, it is very convenient to execute dos commands from within TotCommander, hence don't actually drop into a shell many times. It sort of like when onejust runs a command or program.

I was hoping ther was some kind of system variable or setting that could be changed on windows to allow me to set my own del cmd, but I reakon I'll have to work hard at disciplining myself from now on, and hope that MS addresses such a simple bug in future releases.

Please excuse me for asking this question in this forum - I probably should have asked it in a lounge topic, but thought the windows c++ community might have some answers or workarounds for this issue.
The problem goes back to DOS. The DOS wildcards were never really implemented properly and many of those old programs/commands that still use them are maintained for backwards compatibility.
Topic archived. No new replies allowed.