|I'm not 100% sure as I don't do DOS batchfiles as well as I script in UNIX but I suspect the issue is the %0 I know is UNIX, $0 is the name of the program (ie: what's typed to invoke the program). |
I believe that is the variable that stores whatever is typed in at the command line (batchfile name). In this case, the name of the batchfile. Ergo, (if I'm right) when you double click on the batchfile in windows explorer, there is nothing stored in that variable.
If I'm right, I suspect you're typing the entire batchfile name in the following format: batchfile.bat to invoke it from the command line. Since it's got the .bat extension, this shouldn't be necessary. Try typing just batchfile without the extension. The batchfile should still run but in that case will not delete the batchfile because of the lack of the extension.
To check and see what's stored in that variable, you could put something like:
in the batchfile before the command to delete the batchfile to see what is held in that variable. Run it from both the command line and windows explorer and see what is held in that variable in each instance.
If I'm right, then you would have to add a specific:
command at the end of the batchfile you wish to run from windows explorer to have it actually delete the batchfile at the end of the run.