Making a good batch file can be a lot of fun. But a person is better motivated to do a good job if they have a good reason.
Looking over your original post, I don't see a very good reason for doing this. Pardon me, but that freeware program you're referring to works very well just the way it is. So I don't get the point. You already know that it's going to give itself another name and delete the prior version. So what's wrong with that?
But, if you insist, it's quite easy to find a file that has a certain name or has some ambiguity in the name. Now the question would be; Suppose to found 100 files that have ambiguous names. Do you want to delete them all? You want to rename the mall? Or just rename the last one and delete all the others?
You objective is either not clear or in unreasonable. Remember, Reason must precede logic.
Thanks for the help. The purpose of this batch file, is that when the common box dialog that Autorun launches, it calls this batch file. I was creating the ability for the user to open the program every time it clicks on the desired option of the Autorun Select Option Dialog. As I said, I can do this everytime I want if the file I'm looking for is named Mx One 0001, for example, as I said.
But when I do want to execute it, via the command line, in order for it to be called, executable files cannot have spaces in their names, so that's why I have to rename Mx?One?0001.exe to MxOne_Antivirus.exe, that is a valid executable file name at Command prompt.
The reason I'm doing, is for a school project, hehe sorry to not mention that.
My logic behind this, is to look the file name with an Index, as BC_Programmer stated with a VB Script instead of a Batch file; first I rename it (obviously a command prompt shows up as usual) and then, it renames Mx One 0001.exe IF Found
IF NOT EXIST, then I have to look over the removable drive (only at its root) for the *.exe name containg at Least Mx One+an Index over it, then again, IF FOUND, rename that file to MxOne_Antivirus.exe that is a valid executable filename and last, launch it via command prompt (batch file), repeating this operation several times with a limit. (similar to search until found, obviously this limit has to be a little bigger).
If this is more complex, and there's another portable, or practical solution like C, C++ or Java, or another programming language, please suggest
Thanks
PD With an Index I mean that the file has an ambiguity in its name, following your advice. This ambiguity is that the file deletes itself when you update, and changes its version that follows a sequence. So I do want to look up for the filename with an Index over its String name, and if found rename... bla..