前言
在內網環境中我們經常會使用NAS或者Samba在Windows中對映網路驅動器,方便區域網使用者實時共享交換資料。但當儲存在網路或對映網路上的任何檔案被刪除時,該檔案將被永久刪除。它不會去到本地計算機回收站,也不會去到伺服器的回收站,我通過google在mydigitallife和microsoft technet中搜尋到很多方法,但針對不同作業系統且涉及到域使用者管理的複雜情況下,單純的依賴登錄檔修改可能已經支撐不住需求的膨脹了。在所有的方法中使用Network Recycle Bin可以輕鬆解決對映網路驅動器上的回收站。
使用Network Recycle Bin為區域網巧設“回收站”
更新歷史
2018年04月20日 - 初稿
閱讀原文 - https://wsgzao.github.io/post/network-recycle-bin/
擴充套件閱讀
Network Recycle Bin Tool - http://www.networkrecyclebin.info/index.html
如何啟用對映網路驅動器上的回收站
對映驅動器不過是將本地驅動器連線到另一臺計算機上特別分配的共享目錄或資料夾。 一旦驅動器被對映,您就可以訪問共享資源,您可以像對待您的系統本地一樣對待它。可以將多個計算機驅動器對映到共享資源,並利用此網路空間。
當儲存在網路或對映網路上的任何檔案被刪除時,該檔案將被永久刪除。 它不會去到本地計算機回收站,也不會去到伺服器的回收站。 為了避免將來出現這種資料丟失情況,您可以在對映的網路驅動器上啟用回收站。 按照以下給出的步驟在對映的網路驅動器上啟用回收站.
- 將網路驅動器對映到要使用的網路共享。 確保登入後重新連線驅動器
- 然後進入C:> 使用者 > 使用者名稱
- 右鍵單擊該位置的任何資料夾,然後單擊 屬性 > 位置選項卡
- 單擊移動並瀏覽根驅動器(在步驟1中對映),然後點選選擇資料夾
- 然後點選 好 並當對話方塊出現命中 是
- 只需在PC上為每個使用者重複這些步驟
注意:要驗證此過程是否正常工作,請右鍵單擊回收站並轉至屬性,並檢查網路驅動器是否在回收站的位置列中列出。
需要注意的事情
這僅適用於通過對映的網路驅動器而不是UNC路徑訪問的檔案。 我們舉一個例子:如果你已經將\server\share對映到E:並從這個E:驅動器中刪除了一些東西,那麼它將會進入回收站。 但是,如果您瀏覽到\server\share並擦除檔案,它將被永久刪除。
Enable Recycle Bin on mapped network drives
方案1,通過重定向檔案位置的方式我自己在Windows 10下測試可用,但Windows 7失敗了
https://forums.mydigitallife.net/threads/tip-network-recycle-bin.16974/
You may have noticed that when you delete a file stored on a network location or mapped network drive that the file is permanently deleted. It does not go to the local computer's recycle bin and does not go to the server's recycle bin. I have discovered a work-around that extends recycle bin coverage to include mapped network drives. The solution is not 100% perfect, but works extremely well and does not rely on Shadow Copies or 3rd-party software.
Here's how:
- Map a network drive to the network share you want to use. Make sure that the drive is re-connected on logon. If you don't know how to do this, search Google.
- Browse to C:\users<user name>.
- Right-click on one of the folders in this location (I chose saved games) and click properties.
- Select the Location tab.
- Click Move, browse to to root of the drive you mapped in step 1, and click Select Folder.
- Click Ok and click yes in the dialogue box that appears.
- Repeat these same steps for all users on the computer.
方案2,通過修改登錄檔搞定回收站問題,實際測試喜憂參半,通用性不高,不推薦
https://social.technet.microsoft.com/Forums/windows/en-US/a349801f-398f-4139-8e8b-b0a92f599e2b/enable-recycle-bin-on-mapped-network-drives
Just copy and paste the following into notepad and save it as "Network Recycling Bin - auto make registry file.bat"
echo off
REM ========== MAIN FUNCTION ========================
Call :CreateREGfile
PAUSE
goto :eof
REM ========== SUB FUNCTIONS ========================
:CreateREGfile
set /p RelativePath=Enter current mapped path of drive (e.g. X:\FileShare\D_Drive):
REM replace \ with \\ (for reg value its a requirement)
Set RelativePath=%RelativePath:\=\\%
set /p MaxBinSize_Dec=Enter max size (in mb) (eg 11gb=11000):
call :toHex %MaxBinSize_Dec% MaxBinSize_Hex
Set outputREG="Network Recycling Bin - %RelativePath:~0,1% Drive (%MaxBinSize_Dec%mb).reg"
call :MakeGUID_VBS NewGUID
REM echo My new GUID : %NewGUID%
echo Windows Registry Editor Version 5.00 > %outputREG%
echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\%NewGUID%] >> %outputREG%
echo "RelativePath"="%RelativePath%" >> %outputREG%
echo "Category"=dword:00000004 >> %outputREG%
echo "Name"="NetworkDrive2RecyclingBin_%NewGUID:~1,5%" >> %outputREG%
REM The "Name" value is required, but is not the name that will be shown if you right-click on the Recycle Bin and select properties. That will be autoset to the network drive name.
echo.>> %outputREG%
echo [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\BitBucket\KnownFolder\%NewGUID%] >> %outputREG%
echo "MaxCapacity"=dword:%MaxBinSize_Hex% >> %outputREG%
echo "NukeOnDelete"=dword:00000000 >> %outputREG%
goto :eof
:MakeGUID_VBS
echo set obj = CreateObject("Scriptlet.TypeLib") > TEMP_generateGUID.vbs
echo WScript.Echo obj.GUID >> TEMP_generateGUID.vbs
FOR /F "usebackq tokens=*" %%rin (`CSCRIPT "TEMP_generateGUID.vbs"`)DO SET RESULT=%%r
set %1=%RESULT%
del TEMP_generateGUID.vbs
goto :eof
:toDec
:: todec hex dec -- convert a hexadecimal number to decimal
:: -- hex [in] - hexadecimal number to convert
:: -- dec [out,opt] - variable to store the converted decimal number in
SETLOCAL
set /a dec=0x%~1
( ENDLOCAL & REM RETURN VALUES
IF "%~2" NEQ "" (SET %~2=%dec%)ELSE ECHO.%dec%
)
EXIT /b
:toHex
:: eg call :toHex dec hex -- convert a decimal number to hexadecimal, i.e. -20 to FFFFFFEC or 26 to 0000001A
:: -- dec [in] - decimal number to convert
:: -- hex [out,opt] - variable to store the converted hexadecimal number in
::Thanks to 'dbenham' dostips forum users who inspired to improve this function
:$created 20091203 :$changed 20110330 :$categories Arithmetic,Encoding
:$source http://www.dostips.com
SETLOCAL ENABLEDELAYEDEXPANSION
set /a dec=%~1
set "hex="
set "map=0123456789ABCDEF"
for /L %%Nin (1,1,8)do (
set /a "d=dec&15,dec>>=4"
for %%Din (!d!)do set "hex=!map:~%%D,1!!hex!"
)
rem !!!! REMOVE LEADING ZEROS by activating the next line, e.g. will return 1A instead of 0000001A
rem for /f "tokens=* delims=0" %%A in ("%hex%") do set "hex=%%A"&if not defined hex set "hex=0"
( ENDLOCAL & REM RETURN VALUES
IF "%~2" NEQ "" (SET %~2=%hex%)ELSE ECHO.%hex%
)
EXIT /b
:eof
複製程式碼
Network Recycle Bin Tool簡介
本文主要使用Network Recycle Bin Tool Personal Client Machine Edition客戶端
Server Edition
version 6.1.1.3
This version has been designed for the server usage. You should install it on the server to monitor shared folders. When network user will delete a shared file it will copy it to the "network recycle bin". You have not install any additional software on client machines.
Personal Client Machine Edition
version 5.2.3.8
When you delete a file stored on a network location
or mapped network drive that the file is permanently deleted. It does not go to the local computer's recycle bin and does not go to the server's recycle bin
.
How to enable a recycle bin for shared folders on a network ? There is the proper solution of restoring and securing your information even after deleting it - The Network Recycle Bin Tool allows you to recover deleted files
.
Once you have this tool in your system, it will automatically keep a track of all the network deleted files and you can easily recover them. Instead of removing the files, this tool sends them directly to its predefined recycle bin folder.
There are various options to tune it up. For example: you can set size limits for files stored in the Network Recycle Bin
, you can define the list of network drives or network folders to track deleted files.
Additionaly it offers you the Protect Files tool which prevents deletion
of network files for specified folders according the file mask. Export and import functions help you to install software with same options on network machines. The password control
disallows unauthorized access.
In the long run, losing your important network files and information accidentally is not an issue these days. Instead of getting anxious and worried, feel free to download network recycle bin tool from any reliable source and make sure that you have pre-installed this recovery tool
.
Network Recycle Bin Tool使用方法
使用方法非常簡單,安裝好Network Recycle Bin Tool只需要4步即可,其它需求可以自定義Options
- 選擇
Protect Folders
新增你需要保護的的對映網路驅動器 - 在
Options
中確認刪除檔案的儲存路徑,預設可以不修改 - 在對映網路驅動器中嘗試刪除測試檔案,在
Deleted Files
可以看到刪除的檔案 - 可以批量選中要恢復或者刪除的檔案點選
Recovery Files
或者Delete Files