Quick summary: I am a tinkerer and I hate to click through the GUI, I don't need $Recycle.Bin
so I want to disable it by using Set-ItemProperty
to modify registry.
As in title, I want to use regedit.exe (I know reg add
and stuff but I don't use reg
, instead I use Set-ItemProperty
and its cohorts to do the work and I would like to put all commands in one file) and gpedit.msc (again registry, as Group Policy settings are stored in registry) to disable $Recycle.Bin
for all drives and display delete confirmation box by default, this means modifying both HKEY_LOCAL_MACHINE
and HKEY_CURRENT_USER
.
In short, the desired effect is, when any user (all user accounts are administrator accounts owned by me, as I am the only user, because the user accounts can get bad and it would be hard to fix the accounts once they are bad, and they are very prone to get bad if a blackout happens while the computer is running...) clicks to delete a file/files on any drive, a delete confirmation box pops up; After confirmation the file(s) is/are deleted directly WITHOUT going through $Recycle.Bin. And there isn't this undeletable $Recycle.Bin folder present in any root directory of the drives.
Of course I know this:
And that exactly what I am trying to avoid. Because I have to manually click Don't move files to the Recycle Bin...
checkbox for every drive. Also I can't get rid of this $Recycle.Bin
folder, if I delete it, it simply magically reappears after F5...
I found this registry key and value after some Googling:
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Explorer\BitBucket]
"NukeOnDelete"=dword:00000001
But the source says it applies to Windows 7, I never used Windows 7, does that value prevent the recreation of $Recycle.Bin? Does it still work on Windows 10?
I also found this:
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer]
"NoRecycleFiles"=dword:00000001
But when I tried to open that path in regedit an error sound is played and current location isn't changed so the path doesn't exist...
And this:
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer]
"ConfirmFileDelete"=dword:00000001
This seems to enable "Delete Confirmation dialog", what I don't know is, does this setting affect all drives? And does it show the dialog, then just move the file to $Recycle.Bin after confirmation if $Recycle.Bin isn't disabled?
How to disable $Recycle.Bin for all users and all drives by default? And how to prevent $Recycle.Bin from returning? Any help is appreciated.
Update
It is strange, I have enabled Do not move deleted files to the Recycle Bin
policy, still can get to HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer
in regedit... Just pressed F5 and found the key...
Update1
With all above mentioned settings enabled, I tried to delete the $Recycle.Bin folders with Explorer, result: they reappear after pressing F5
Used rd X:\$Recycle.Bin /s /q
and they didn't recur after multiple F5 presses so far, I don't know why though, I thought it would have the same effect as deleting it in explorer.exe...
But what does Don't move file to the Recycle Bin. Remove files immediately when deleted.
do? What registry key and value does it write? Can anyone tell me?
The $Recycle.Bin folders have reappeared... I have confirmed, clicking on "Recycle Bin" folder will recreate the $Recycle.Bin folders...
It seems that Don't move...
sets nukeondelete to enabled on current drive.
I have written a PowerShell script to automatically disable Recycle Bin on all drives, using Get-Volume and Set-ItemProperty;
This is the script I mentioned, I post it here in case anyone else might want to do it:
$volumes=Get-Volume | where {$_.FileSystem -eq "NTFS"}
$Drives=foreach ($volume in $volumes) {
$DriveLetter=$Volume.DriveLetter
[string]$ObjectId=($Volume.ObjectId | Select-String -Pattern "Volume{[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}}\\").Matches.Value.SubString(6,38)
Remove-Item -Path $('{0}:\$Recycle.Bin' -f $DriveLetter) -Force -Recurse -ErrorAction SilentlyContinue
New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\BitBucket\Volume\$ObjectId" -ErrorAction SilentlyContinue | Out-Null
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\BitBucket\Volume\$ObjectId" -Name NukeOnDelete -Type DWord -Value 1
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\BitBucket\Volume\$ObjectId" -Name MaxCapacity -Type DWord -Value 0
}
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\BitBucket" -Name NukeOnDelete -Type DWord -Value 1
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\BitBucket" -Name MaxCapacity -Type DWord -Value 0
I am now looking for ways to prevent creation of $Recycle.Bin, I am thinking about group policy and security options.
I have found this:**GPO - How to block creation of folder and files in root directory in Windows 10
Don't know if it will work though(I am only trying to block recycle bin), and how to do it with security options?