No, it appears not to. If you echo %errorlevel%
after either a successful or failed rmdir
, you get 0
in both cases:
c:\pax> mkdir qqq
c:\pax> rmdir qqq
c:\pax> echo %errorlevel%
0
c:\pax> rmdir qqq
The system cannot find the file specified.
c:\pax> echo %errorlevel%
0
For that particular use case, you're probably best off checking the directory existence afterwards:
if exist dodgy\. rmdir dodgy
if exist dodgy\. echo dodgy directory still exists
Interestingly enough, if you call on a separate copy of cmd.exe
to perfom the operation, you can get the error level:
c:\pax> mkdir qqq
c:\pax> cmd /c rmdir qqq
c:\pax> echo %errorlevel%
0
c:\pax> cmd /c rmdir qqq
The system cannot find the file specified.
c:\pax> echo %errorlevel%
2
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.