网上收集到一个备份恢复文件夹NTFS安全设置的batch脚本,很实用。

 
  
  1. @echo off 
  2. REM The syntax for using NTFSBKP.bat is: NTFSBKP DriveOrFolder DestinationFolder BKP|RST 
  3. :: Where
  4. :: DriveOrFolder  is the drive, or folder, including files and sub-folders, whose NTFS security you wish to backup or restore.  
  5. :: DestinationFolder  is the destination folder that will contain /does contain two files that hold backed up security attributes. 
  6. :: BKP|RST BKP causes NTFSBKP.bat to backup the NTFS security. RST causes NTFSBKP.bat to restore the NTFS security from the previous backup. 
  7.  
  8. If {%3}=={} @echo Syntax: NTFSBKP DriveOrFolder DestinationFolder BKP^|RST&goto :EOF 
  9. if not exist %1 @echo NTFSBKP - %1 NOT FOUND.&goto :EOF 
  10. if not exist %2 @echo NTFSBKP - %2 NOT FOUND.&goto :EOF 
  11. if /i {%1}=={%2} @echo Syntax: NTFSBKP DriveOrFolder DestinationFolder BKP^|RST&goto :EOF 
  12. if /i {%3}=={BKP} goto OK 
  13. if /i {%3}=={RST} goto OK 
  14. @echo Syntax: NTFSBKP DriveOrFolder DestinationFolder BKP^|RST&goto :EOF 
  15. :OK 
  16. setlocal 
  17. set DorF=%1# 
  18. set DorF=%DorF:"=% 
  19. set DorF=%DorF:\#=% 
  20. set DorF=%DorF:#=% 
  21. set Fld=%2# 
  22. set Fld=%Fld:"=% 
  23. set Fld=%Fld:\#=% 
  24. set Fld=%Fld:#=% 
  25. set Sw=%3 
  26. set F1=%DorF% 
  27. set F1=%F1::\=_% 
  28. set F1=%F1:\=_% 
  29. set F2="%Fld%\%F1%_ALL.log" 
  30. set F1="%Fld%\%F1%.log" 
  31. if /i "%Sw%" EQU "RST" goto Restore 
  32. set D1="%DorF%" 
  33. set D2="%DorF%\*.*" 
  34. if exist %F1% del /q %F1% 
  35. if exist %F2% del /q %F2% 
  36. subinacl /noverbose /nostatistic /outputlog=%F1% /subdirectories %D1% /display 
  37. subinacl /noverbose /nostatistic /outputlog=%F2% /subdirectories %D2% /display 
  38. endlocal 
  39. goto :EOF 
  40. :Restore 
  41. if not exist %F1% goto :Rest1 
  42. if not exist %F2% goto :Rest2 
  43. subinacl /nostatistic /playfile %F1% 
  44. subinacl /nostatistic /playfile %F2% 
  45. endlocal 
  46. goto :EOF 
  47. :Rest1 
  48. @echo NTFSBKP %1 %2 %3 - %F1% NOT FOUND. 
  49. endlocal 
  50. goto :EOF 
  51. :Rest2 
  52. @echo NTFSBKP %1 %2 %3 - %F2% NOT FOUND. 
  53. endlocal