I have not found a way to get the error code, if returned, of rmdir. It seems like the MS-DOS internal commands do not return an error code. Can someone confirm that?
How does a script that uses these commands know if the commands succeed or fail in order to decide the next step? The easiest way is to read their return code, if it is returned.
Thanks in advance.
No, it appears not to. If you
echo %errorlevel%after either a successful or failedrmdir, you get0in both cases:For that particular use case, you’re probably best off checking the directory existence afterwards:
Interestingly enough, if you call on a separate copy of
cmd.exeto perfom the operation, you can get the error level:However, I’m unconvinced that’s better than simply checking that the directory is gone after you remove it, since it requires you to start up a whole new command interpreter.