(I also have this problem with Samba 3) ~$ smbclient -U user%pass \\\\server\\outbox -c "rmdir [PROTECTED-FOLDER]" > ... > NT_STATUS_UNSUCCESSFUL removing remote directory file \[PROTECTED-FOLDER] ~$ echo $? > 0 As this is an error, smbclient should return 1. Please note that smbclient already returns 1, for example when it fails to rename the very same folder. If you want a proper patch, I can provide it. Otherwise, you just need to add a "return 1;" after this line: http://gitweb.samba.org/?p=samba.git;a=blob;f=source4/client/client.c#l2225 You may also want to check all return codes in the same file. For example, there is apparently the same problem when trying to delete files: http://gitweb.samba.org/?p=samba.git;a=blob;f=source4/client/client.c#l1546 This fix may not be just cosmetic. For example, return codes are useful when writing tests.