Prevent Windows from creating $RECYCLE.BIN folder on Samba share
Browsing a Samba share on a Windows machine, I notice after a short while that it has created a $RECYCLE.BIN
folder in within the network share, usually containing a single desktop.ini
file. How do I prevent my Windows clients from creating this file, either on the Samba server (Linux) or the Windows clients themselves?
Even if Windows creates the folder and I delete it on the server side, without deleting any other files, eventually the folder will re-appear (with desktop.ini
inside of it). It's as if Windows is creating and deleting desktop.ini
at random intervals.
A similar question asked how to prevent creation or hide this file, but I only want to know how to prevent creation.
linux windows network-shares samba
add a comment |
Browsing a Samba share on a Windows machine, I notice after a short while that it has created a $RECYCLE.BIN
folder in within the network share, usually containing a single desktop.ini
file. How do I prevent my Windows clients from creating this file, either on the Samba server (Linux) or the Windows clients themselves?
Even if Windows creates the folder and I delete it on the server side, without deleting any other files, eventually the folder will re-appear (with desktop.ini
inside of it). It's as if Windows is creating and deleting desktop.ini
at random intervals.
A similar question asked how to prevent creation or hide this file, but I only want to know how to prevent creation.
linux windows network-shares samba
I can run a command on either side, but I am looking for a command to prevent the creation, rather than a command to run every time to delete the file(s).
– palswim
Jan 22 at 22:01
add a comment |
Browsing a Samba share on a Windows machine, I notice after a short while that it has created a $RECYCLE.BIN
folder in within the network share, usually containing a single desktop.ini
file. How do I prevent my Windows clients from creating this file, either on the Samba server (Linux) or the Windows clients themselves?
Even if Windows creates the folder and I delete it on the server side, without deleting any other files, eventually the folder will re-appear (with desktop.ini
inside of it). It's as if Windows is creating and deleting desktop.ini
at random intervals.
A similar question asked how to prevent creation or hide this file, but I only want to know how to prevent creation.
linux windows network-shares samba
Browsing a Samba share on a Windows machine, I notice after a short while that it has created a $RECYCLE.BIN
folder in within the network share, usually containing a single desktop.ini
file. How do I prevent my Windows clients from creating this file, either on the Samba server (Linux) or the Windows clients themselves?
Even if Windows creates the folder and I delete it on the server side, without deleting any other files, eventually the folder will re-appear (with desktop.ini
inside of it). It's as if Windows is creating and deleting desktop.ini
at random intervals.
A similar question asked how to prevent creation or hide this file, but I only want to know how to prevent creation.
linux windows network-shares samba
linux windows network-shares samba
edited Jan 18 at 6:43
palswim
asked Jan 17 at 21:44
palswimpalswim
1,73282951
1,73282951
I can run a command on either side, but I am looking for a command to prevent the creation, rather than a command to run every time to delete the file(s).
– palswim
Jan 22 at 22:01
add a comment |
I can run a command on either side, but I am looking for a command to prevent the creation, rather than a command to run every time to delete the file(s).
– palswim
Jan 22 at 22:01
I can run a command on either side, but I am looking for a command to prevent the creation, rather than a command to run every time to delete the file(s).
– palswim
Jan 22 at 22:01
I can run a command on either side, but I am looking for a command to prevent the creation, rather than a command to run every time to delete the file(s).
– palswim
Jan 22 at 22:01
add a comment |
1 Answer
1
active
oldest
votes
Warning:
With this answer, I am not encouraging readers to delete Recycle Bin in their Windows OS. Recycle Bin helps to recover files/folder from accidental deletion. Do not attempt these steps in a working important PC.
Used trick:
Windows creates a hidden $RECYCLE.BIN
folder for Recycle Bin in every mounted drives. Generally current logged-in user has no ownership of this folder. To delete this folder, user has to take ownership of it. After deleting this folder, Windows creates automatically after sometime. To prevent this, create a file of same name. Windows can't/don't override a file with a folder of same name.
Procedure:
Delete the Recycle Bin folder with these following commands as administrator. Let assume the drive letter is D:
. Replace the drive letter as needed. Here are the steps:
- Take ownership:
Takeown /F "D:$RECYCLE.BIN" /R /D Y
- Change permission:
Icacls "D:$RECYCLE.BIN" /grant Everyone:(OI)(CI)(F) /T
- Remove system attributes (optional):
Attrib -R -S -H "D:$RECYCLE.BIN" /S /D
- Delete folder:
Rmdir /S /Q "D:$RECYCLE.BIN"
- Create an empty file:
echo.> "D:$RECYCLE.BIN"
Alternatively, combine those steps in a single batch file (.bat) and run it as administrator:
@echo off
Takeown /F "D:$RECYCLE.BIN" /R /D Y
Icacls "D:$RECYCLE.BIN" /grant Everyone:(OI)(CI)(F) /T
REM This is a comment
REM Attrib -R -S -H "D:$RECYCLE.BIN" /S /D
Rmdir /S /Q "D:$RECYCLE.BIN" & echo.> "D:$RECYCLE.BIN"
pause
I combine the last two steps in one line so that Windows doesn't create that folder in meantime. To revert back, just delete the empty file and restart File Explorer.
Further details:
Takeown command
Icacls command
Attrib command
Rmdir command
While this might prevent creation of the file, I actually wanted to prevent the existence of any$RECYCLE.BIN
file or folder.
– palswim
Feb 5 at 18:22
Yes; my question also didn't specify that I would like to keep the Samba server running, so you could have answered "Stop the Samba service", but I also would not have accepted that answer.
– palswim
6 hours ago
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1395546%2fprevent-windows-from-creating-recycle-bin-folder-on-samba-share%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Warning:
With this answer, I am not encouraging readers to delete Recycle Bin in their Windows OS. Recycle Bin helps to recover files/folder from accidental deletion. Do not attempt these steps in a working important PC.
Used trick:
Windows creates a hidden $RECYCLE.BIN
folder for Recycle Bin in every mounted drives. Generally current logged-in user has no ownership of this folder. To delete this folder, user has to take ownership of it. After deleting this folder, Windows creates automatically after sometime. To prevent this, create a file of same name. Windows can't/don't override a file with a folder of same name.
Procedure:
Delete the Recycle Bin folder with these following commands as administrator. Let assume the drive letter is D:
. Replace the drive letter as needed. Here are the steps:
- Take ownership:
Takeown /F "D:$RECYCLE.BIN" /R /D Y
- Change permission:
Icacls "D:$RECYCLE.BIN" /grant Everyone:(OI)(CI)(F) /T
- Remove system attributes (optional):
Attrib -R -S -H "D:$RECYCLE.BIN" /S /D
- Delete folder:
Rmdir /S /Q "D:$RECYCLE.BIN"
- Create an empty file:
echo.> "D:$RECYCLE.BIN"
Alternatively, combine those steps in a single batch file (.bat) and run it as administrator:
@echo off
Takeown /F "D:$RECYCLE.BIN" /R /D Y
Icacls "D:$RECYCLE.BIN" /grant Everyone:(OI)(CI)(F) /T
REM This is a comment
REM Attrib -R -S -H "D:$RECYCLE.BIN" /S /D
Rmdir /S /Q "D:$RECYCLE.BIN" & echo.> "D:$RECYCLE.BIN"
pause
I combine the last two steps in one line so that Windows doesn't create that folder in meantime. To revert back, just delete the empty file and restart File Explorer.
Further details:
Takeown command
Icacls command
Attrib command
Rmdir command
While this might prevent creation of the file, I actually wanted to prevent the existence of any$RECYCLE.BIN
file or folder.
– palswim
Feb 5 at 18:22
Yes; my question also didn't specify that I would like to keep the Samba server running, so you could have answered "Stop the Samba service", but I also would not have accepted that answer.
– palswim
6 hours ago
add a comment |
Warning:
With this answer, I am not encouraging readers to delete Recycle Bin in their Windows OS. Recycle Bin helps to recover files/folder from accidental deletion. Do not attempt these steps in a working important PC.
Used trick:
Windows creates a hidden $RECYCLE.BIN
folder for Recycle Bin in every mounted drives. Generally current logged-in user has no ownership of this folder. To delete this folder, user has to take ownership of it. After deleting this folder, Windows creates automatically after sometime. To prevent this, create a file of same name. Windows can't/don't override a file with a folder of same name.
Procedure:
Delete the Recycle Bin folder with these following commands as administrator. Let assume the drive letter is D:
. Replace the drive letter as needed. Here are the steps:
- Take ownership:
Takeown /F "D:$RECYCLE.BIN" /R /D Y
- Change permission:
Icacls "D:$RECYCLE.BIN" /grant Everyone:(OI)(CI)(F) /T
- Remove system attributes (optional):
Attrib -R -S -H "D:$RECYCLE.BIN" /S /D
- Delete folder:
Rmdir /S /Q "D:$RECYCLE.BIN"
- Create an empty file:
echo.> "D:$RECYCLE.BIN"
Alternatively, combine those steps in a single batch file (.bat) and run it as administrator:
@echo off
Takeown /F "D:$RECYCLE.BIN" /R /D Y
Icacls "D:$RECYCLE.BIN" /grant Everyone:(OI)(CI)(F) /T
REM This is a comment
REM Attrib -R -S -H "D:$RECYCLE.BIN" /S /D
Rmdir /S /Q "D:$RECYCLE.BIN" & echo.> "D:$RECYCLE.BIN"
pause
I combine the last two steps in one line so that Windows doesn't create that folder in meantime. To revert back, just delete the empty file and restart File Explorer.
Further details:
Takeown command
Icacls command
Attrib command
Rmdir command
While this might prevent creation of the file, I actually wanted to prevent the existence of any$RECYCLE.BIN
file or folder.
– palswim
Feb 5 at 18:22
Yes; my question also didn't specify that I would like to keep the Samba server running, so you could have answered "Stop the Samba service", but I also would not have accepted that answer.
– palswim
6 hours ago
add a comment |
Warning:
With this answer, I am not encouraging readers to delete Recycle Bin in their Windows OS. Recycle Bin helps to recover files/folder from accidental deletion. Do not attempt these steps in a working important PC.
Used trick:
Windows creates a hidden $RECYCLE.BIN
folder for Recycle Bin in every mounted drives. Generally current logged-in user has no ownership of this folder. To delete this folder, user has to take ownership of it. After deleting this folder, Windows creates automatically after sometime. To prevent this, create a file of same name. Windows can't/don't override a file with a folder of same name.
Procedure:
Delete the Recycle Bin folder with these following commands as administrator. Let assume the drive letter is D:
. Replace the drive letter as needed. Here are the steps:
- Take ownership:
Takeown /F "D:$RECYCLE.BIN" /R /D Y
- Change permission:
Icacls "D:$RECYCLE.BIN" /grant Everyone:(OI)(CI)(F) /T
- Remove system attributes (optional):
Attrib -R -S -H "D:$RECYCLE.BIN" /S /D
- Delete folder:
Rmdir /S /Q "D:$RECYCLE.BIN"
- Create an empty file:
echo.> "D:$RECYCLE.BIN"
Alternatively, combine those steps in a single batch file (.bat) and run it as administrator:
@echo off
Takeown /F "D:$RECYCLE.BIN" /R /D Y
Icacls "D:$RECYCLE.BIN" /grant Everyone:(OI)(CI)(F) /T
REM This is a comment
REM Attrib -R -S -H "D:$RECYCLE.BIN" /S /D
Rmdir /S /Q "D:$RECYCLE.BIN" & echo.> "D:$RECYCLE.BIN"
pause
I combine the last two steps in one line so that Windows doesn't create that folder in meantime. To revert back, just delete the empty file and restart File Explorer.
Further details:
Takeown command
Icacls command
Attrib command
Rmdir command
Warning:
With this answer, I am not encouraging readers to delete Recycle Bin in their Windows OS. Recycle Bin helps to recover files/folder from accidental deletion. Do not attempt these steps in a working important PC.
Used trick:
Windows creates a hidden $RECYCLE.BIN
folder for Recycle Bin in every mounted drives. Generally current logged-in user has no ownership of this folder. To delete this folder, user has to take ownership of it. After deleting this folder, Windows creates automatically after sometime. To prevent this, create a file of same name. Windows can't/don't override a file with a folder of same name.
Procedure:
Delete the Recycle Bin folder with these following commands as administrator. Let assume the drive letter is D:
. Replace the drive letter as needed. Here are the steps:
- Take ownership:
Takeown /F "D:$RECYCLE.BIN" /R /D Y
- Change permission:
Icacls "D:$RECYCLE.BIN" /grant Everyone:(OI)(CI)(F) /T
- Remove system attributes (optional):
Attrib -R -S -H "D:$RECYCLE.BIN" /S /D
- Delete folder:
Rmdir /S /Q "D:$RECYCLE.BIN"
- Create an empty file:
echo.> "D:$RECYCLE.BIN"
Alternatively, combine those steps in a single batch file (.bat) and run it as administrator:
@echo off
Takeown /F "D:$RECYCLE.BIN" /R /D Y
Icacls "D:$RECYCLE.BIN" /grant Everyone:(OI)(CI)(F) /T
REM This is a comment
REM Attrib -R -S -H "D:$RECYCLE.BIN" /S /D
Rmdir /S /Q "D:$RECYCLE.BIN" & echo.> "D:$RECYCLE.BIN"
pause
I combine the last two steps in one line so that Windows doesn't create that folder in meantime. To revert back, just delete the empty file and restart File Explorer.
Further details:
Takeown command
Icacls command
Attrib command
Rmdir command
answered Jan 25 at 10:37
BiswapriyoBiswapriyo
2,92631342
2,92631342
While this might prevent creation of the file, I actually wanted to prevent the existence of any$RECYCLE.BIN
file or folder.
– palswim
Feb 5 at 18:22
Yes; my question also didn't specify that I would like to keep the Samba server running, so you could have answered "Stop the Samba service", but I also would not have accepted that answer.
– palswim
6 hours ago
add a comment |
While this might prevent creation of the file, I actually wanted to prevent the existence of any$RECYCLE.BIN
file or folder.
– palswim
Feb 5 at 18:22
Yes; my question also didn't specify that I would like to keep the Samba server running, so you could have answered "Stop the Samba service", but I also would not have accepted that answer.
– palswim
6 hours ago
While this might prevent creation of the file, I actually wanted to prevent the existence of any
$RECYCLE.BIN
file or folder.– palswim
Feb 5 at 18:22
While this might prevent creation of the file, I actually wanted to prevent the existence of any
$RECYCLE.BIN
file or folder.– palswim
Feb 5 at 18:22
Yes; my question also didn't specify that I would like to keep the Samba server running, so you could have answered "Stop the Samba service", but I also would not have accepted that answer.
– palswim
6 hours ago
Yes; my question also didn't specify that I would like to keep the Samba server running, so you could have answered "Stop the Samba service", but I also would not have accepted that answer.
– palswim
6 hours ago
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1395546%2fprevent-windows-from-creating-recycle-bin-folder-on-samba-share%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I can run a command on either side, but I am looking for a command to prevent the creation, rather than a command to run every time to delete the file(s).
– palswim
Jan 22 at 22:01