@echo off
	goto begin

::-----------------------------------------------------------------------------
:: File Name: "xcpt.bat" - eXtended CoPy Test BATch for Windows7 HP 64bit(x64)
:: and the related Backup/Copy Softwares
::
:: Copyright: Public Domain Software (NOT TO BE SHAREWARE OR FREEWARE)
::
:: Version (??: secondary series; can be revised by somebodies)
:: *.*?? by ***	May be revised for something
::
:: Version (ps: primary series; reserved for S. )
:: 1.1ps by S.  Command path selection etc. modified.
:: 1.0ps by S.	Created for Robocopy, RichCopy, FastCopy, Fire File Copy etc.
::
:: Related Softwares (required):
::
:: - Robocopy in Windows7 Home Premium, 64-bit Version 6.1 (Build 7600)
:: - RichCopy Version: 4,0,217,0 (freeware, 32/64bit)
::   http://technet.microsoft.com/ja-jp/magazine/2009.04.utilityspotlight.aspx
:: - FastCopy(64bit) ver2.03 (Admin) (freeware, 64bit)
::   http://ipmsg.org/tools/fastcopy.html
:: - Fire File Copy  Version : 4.9.1.0(unicode) (freeware, 32bit)
::   http://www.k3.dion.ne.jp/~kitt/pc/sw/ffc/
:: - FileVisor6 ver6.4.7.1 (shareware, 32bit)
::   http://www.lightship.co.jp/FileVisor6/
:: - WinFM2008 V2.13 (Build 419) (x64 - unicode version) (shareware, 64bit)
::   http://homepage3.nifty.com/annsHome/WinFM2008.htm
:: - Far Manager v2.0 build 1666 x64 (2010-09-10) (freeware, 64bit)
::   http://www.farmanager.com/download.php?p=64
:: - SubInAcl version 5.2.3790.1180 (freeware, 32bit)
::   http://www.microsoft.com/downloads/en/details.aspx?FamilyID=e8ba3e56-d8fe-4a91-93cf-ed6985e3927b&displaylang=en
:: - LADS - List Alternate Data Streams 4.10 (freeware, 32bit)
::   http://www.heysoft.de/en/software/lads.php?lang=EN
:: - "xcp.bat" - eXtended CoPy BATch for Windows7 HP 64bit(x64)
::
:: Notes
:: - Attribute characters of Windows7 Explorer
::   (that should be used for Filers, Archivers and Backup/Copy Softwares)
::	Attr:R (READONLY)
::	Attr:H (HIDDEN)
::	Attr:S (SYSTEM)
::	Attr:D (DIRECTORY)
::	Attr:A (ARCHIVE)
::	Attr:N (NORMAL)
::	Attr:T (TEMPORARY)
::	Attr:P (SPARSE_FILE)
::	Attr:L (REPARSE_POINT)
::	Attr:C (COMPRESSED)
::	Attr:O (OFFLINE)
::	Attr:I (NOT_CONTENT_INDEXED)
::	Attr:E (ENCRYPTED)
::	Attr:V (VIRTUAL)
::
:: - Attribute characters (MJL extension)
::   (expected to be used for Filers, Archivers and Backup/Copy Softwares)
::	Attr:M (Volume Mount Points)
::	Attr:J (Junction Points)
::	Attr:L (Symbolic Links only)
::-----------------------------------------------------------------------------

:begin
	set _CP_FSN=
	for /F "usebackq skip=3 tokens=2 delims=:" %%i in (`fsutil fsinfo volumeinfo \`) do (
		if "%%i"==" NTFS"	set _CP_FSN=NTFS
		if "%%i"==" FAT32"	set _CP_FSN=FAT32
		if "%%i"==" FAT"	set _CP_FSN=FAT
		goto eol
	)
:eol
	       if exist      "%ProgramFiles%\Windows Resource Kits\Tools\" (
		set "_CP_RKT=%ProgramFiles%"
	) else if exist "%ProgramFiles(x86)%\Windows Resource Kits\Tools\" (
		set "_CP_RKT=%ProgramFiles(x86)%"
	) else (
		set "_CP_RKT=%SystemDrive%\usr"
	)
	set _CP_RKT=%_CP_RKT%\Windows Resource Kits\Tools\
	if .%1==.-p goto purge
	if .%1==.-a goto arrange
	if .%1==.-t goto test

:usage
	echo Usage:
	echo  %~n0 -p/-a/-t [-man] [-vmp DRV] [ARG..]
	echo -p:   Purge DIR./FILE for Copy Test
	echo -a:   Arrange DIR./FILE for Copy Test
	echo -t:   Copy Test for Backup/Copy Softwares
	echo -man: Enable manual operation for FileVisor6, WinFM2008, Far Manager (with -a )
	echo -vmp: Enable operation for Volume Mount Points (with -a operator)
	echo DRV:  Drive Character (with -a operator, e.g. d: )
	echo ARG:  Optional Argument
	echo.
	echo e.g. %~n0 -p
	echo e.g. %~n0 -a -man -vmp d:
	echo e.g. %~n0 -t
	goto exit

:purge
	echo Purge DIR./FILE for Copy Test =================================================
	for /D %%i in (\X0 \X0_ALL0 \X0_ALL1D \X0_ALL1F \X1 \X2 \X3 \X4 \X5 \X6 \X7) do if exist %%i\ (
		if exist %%i\DIR_0M\ rd /S /Q %%i\DIR_0M
		if exist %%i\DIR_0M\ goto abort
		call xcp -frc -rob -p %%i
		if exist %%i\ rd %%i
		if exist %%i\ goto abort
	)
	echo Done: %~n0
	goto exit

:arrange
	echo Arrange DIR./FILE for Copy Test ===============================================
	for /D %%i in (\X0 \X0_ALL0 \X0_ALL1D \X0_ALL1F \X1 \X2 \X3 \X4 \X5 \X6 \X7) do if exist %%i\ (
		echo Aborted: "%%i" is already exist.
	)
	if .%2==.-vmp if not exist "%~3" (
		echo Aborted: "%~3" is not exist.
		goto exit
	)
	for /D %%i in (\X0 \X0_ALL0 \X0_ALL1D \X0_ALL1F \X1 \X2 \X3 \X4 \X5 \X6 \X7) do if exist %%i\ (
		goto exit
	)

:: Enable/Disable manual operation for FileVisor6(\X5), WinFM2008(\X6), Far Manager(\X7)
	set _CP_MAN=
	if .%2==.-man (
		set _CP_MAN= \X5 \X6 \X7
		shift /2
	)
	for /D %%i in (\X1 \X2 \X3 \X4%_CP_MAN%) do if not exist %%i\ (
		md %%i
		if errorlevel 1 goto abort
	)
	pushd .

:: Arrange DIR./FILE with all Attr. to be reset
	md \X0
	if errorlevel 1 goto abort
	cd \X0
	if errorlevel 1 goto abort

	md DIR_0
	if errorlevel 1 goto abort
	if .%_CP_FSN%==.NTFS (
		mklink /J DIR_0J DIR_0
		if errorlevel 1 goto abort
		mklink /D DIR_0L DIR_0
		if errorlevel 1 goto abort
	)

	echo 4MB_0.TXT> 4MB$0.TXT
	fsutil file createnew 4MB$1.TXT 4194304 > nul
	if errorlevel 1 goto abort
	copy /b 4MB$0.TXT+4MB$1.TXT 4MB_0.TXT > nul
	if errorlevel 1 goto abort
	if exist 4MB$?.TXT del 4MB$?.TXT
	if exist 4MB$?.TXT goto abort
	echo 1KB_0.TXT> 1KB_0.TXT

	cd \
	if errorlevel 1 goto abort
	ren X0 X0_ALL0
	if errorlevel 1 goto abort

:: Arrange DIR. with all Attr. to be set
	md \X0
	if errorlevel 1 goto abort
	cd \X0
	if errorlevel 1 goto abort

	md DIR_1
	if errorlevel 1 goto abort
	if .%_CP_FSN%==.NTFS (
		mklink /J DIR_1J DIR_1
		if errorlevel 1 goto abort
		mklink /D DIR_1L DIR_1
		if errorlevel 1 goto abort
	)

	cd \
	if errorlevel 1 goto abort
	ren X0 X0_ALL1D
	if errorlevel 1 goto abort

:: Arrange FILE with all Attr. to be set
	md \X0
	if errorlevel 1 goto abort
	cd \X0
	if errorlevel 1 goto abort

	echo 4MB_1.TXT> 4MB$0.TXT
	fsutil file createnew 4MB$1.TXT 4194304 > nul
	if errorlevel 1 goto abort
	copy /b 4MB$0.TXT+4MB$1.TXT 4MB_1.TXT > nul
	if errorlevel 1 goto abort
	if exist 4MB$?.TXT del 4MB$?.TXT
	if exist 4MB$?.TXT goto abort
	echo 1KB_1.TXT> 1KB_1.TXT

	cd \
	if errorlevel 1 goto abort
	ren X0 X0_ALL1F
	if errorlevel 1 goto abort

:: Merge arranged DIR./FILE
	md \X0
	if errorlevel 1 goto abort
	popd

	if exist \X0\ call xcp -frc -fc2 -c  \X0 \X0_ALL0
	if exist \X0\ call xcp -frc -fc2 -c  \X0 \X0_ALL1D
:	if exist \X0\ call xcp -frc -fc2 -c  \X0 \X0_ALL1F

	if exist \X0\ call xcp -frc -ric -r  \X0 \X0_ALL0
	if exist \X0\ call xcp -frc -ric -sd \X0 \X0_ALL1D
	if exist \X0\ call xcp -frc -ric -sf \X0 \X0_ALL1F

	for /D %%i in (\X0_ALL0 \X0_ALL1D \X0_ALL1F) do if exist %%i\ (
		call xcp -frc -rob -p %%i
		if exist %%i\ rd %%i
		if exist %%i\ goto abort
	)

	pushd .
	cd \X0
	if errorlevel 1 goto abort
	md DIR_0M
	if errorlevel 1 goto abort
:BUG: Attr:H (HIDDEN) not reset with Attr:A (ARCHIVE) for FILE (reset for DIR.) with RichCopy ("xcp -ric -r DST SRC")
:BUG: Attr:S (SYSTEM) not reset with Attr:A (ARCHIVE) for FILE (reset for DIR.) with RichCopy ("xcp -ric -r DST SRC")
	echo YHA.TXT> YHA.TXT
	attrib +H +A YHA.TXT
	echo YSA.TXT> YSA.TXT
	attrib +S +A YSA.TXT

:: Set Attr:P (SPARSE_FILE) for FILE
	if .%_CP_FSN%==.NTFS for %%i in (4MB_1 1KB_1) do (
		attrib -R -H -S %%i.TXT
		fsutil sparse setflag %%i.TXT
		if errorlevel 1 goto abort
	)

:: Make Alternate Data Streams for DIR./FILE
	if .%_CP_FSN%==.NTFS (
		attrib -R -H -S DIR_1
		echo DIR_0:STREAM.TXT> DIR_0:STREAM.TXT
		echo DIR_0M:STREAM.TXT> DIR_0M:STREAM.TXT
		echo 4MB_0.TXT:STREAM.TXT> 4MB_0.TXT:STREAM.TXT
		echo 1KB_0.TXT:STREAM.TXT> 1KB_0.TXT:STREAM.TXT
		echo DIR_1:STREAM.TXT> DIR_1:STREAM.TXT
		echo 4MB_1.TXT:STREAM.TXT> 4MB_1.TXT:STREAM.TXT
		echo 1KB_1.TXT:STREAM.TXT> 1KB_1.TXT:STREAM.TXT
	)

:: Make Hard Links for FILE
	if .%_CP_FSN%==.NTFS for %%i in (4MB_0 1KB_0 4MB_1 1KB_1) do (
		mklink /H %%iH.TXT %%i.TXT
		if errorlevel 1 goto abort
	)

:: Make Symbolic Links for FILE
	if .%_CP_FSN%==.NTFS for %%i in (4MB_0 1KB_0 4MB_1 1KB_1) do (
		mklink %%iL.TXT %%i.TXT
		if errorlevel 1 goto abort
	)

:: Make Volume Mount Points for DIR.
	if .%2==.-vmp if exist "%~3" (
		if .%_CP_FSN%==.NTFS for /F "usebackq" %%i in (`mountvol %~3 /L`) do (
			echo	mountvol %~3 /L
				mountvol %~3 /L
			if errorlevel 1 goto abort
			echo	mountvol DIR_0M %%i
				mountvol DIR_0M %%i
			if errorlevel 1 goto abort
			echo	mountvol DIR_0M /L
				mountvol DIR_0M /L
			if errorlevel 1 goto abort
		)
		shift /2
		shift /2
	)

:: Enable Very Long Paths over 260 char.
	md  \X0\0\0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcde
	if errorlevel 1 goto abort
	ren \X0\0 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcde
	if errorlevel 1 goto abort

:: Save order of DIR. entries (FAT32/FAT)
	if not .%_CP_FSN%==.NTFS forfiles > XODE.TXT

:: Save Access Control Lists
	if .%_CP_FSN%==.NTFS for /D %%i in (\X0) do if exist %%i\ (
		copy nul XACL_S.TXT  > nul
		copy nul XACL_I.TXT  > nul
		copy nul XACL_SG.TXT > nul
		copy nul XACL_IG.TXT > nul
		copy nul XACL_SS.TXT > nul
		copy nul XACL_IS.TXT > nul

rem		if exist "%_CP_RKT%subinacl.exe" (
			"%_CP_RKT%subinacl" /outputlog=XACL_S.TXT /stringreplaceonoutput=" %%~fi\\"=" " /nostatistic /file * /display=sddl
			if errorlevel 1 goto abort
rem		) else (
			forfiles /C "cmd /U /C if not @file==\"$\" icacls @file /save $ /L & echo.>> $& copy /b XACL_I.TXT+$ XACL_I.TXT" > nul
			if errorlevel 1 goto abort
			if exist $ del $
			if exist $ goto abort
rem		)

rem		"%_CP_RKT%subinacl" /nostatistic /file * /grant="Administrator"=F > nul
rem		if errorlevel 1 goto abort
		icacls * /grant:r "Administrator":"(GA)" /L /Q
		if errorlevel 1 goto abort

rem		if exist "%_CP_RKT%subinacl.exe" (
			"%_CP_RKT%subinacl" /outputlog=XACL_SG.TXT /stringreplaceonoutput=" %%~fi\\"=" " /nostatistic /file * /display=sddl
			if errorlevel 1 goto abort
rem		) else (
			forfiles /C "cmd /U /C if not @file==\"$\" icacls @file /save $ /L & echo.>> $& copy /b XACL_IG.TXT+$ XACL_IG.TXT" > nul
			if errorlevel 1 goto abort
			if exist $ del $
			if exist $ goto abort
rem		)

		md Microsoft
		if errorlevel 1 goto abort

rem		if exist "%_CP_RKT%subinacl.exe" (
rem			"%_CP_RKT%subinacl" /outputlog=xwin.txt /subdirectories "%SystemDrive%\Windows\\" /display=sddl
rem			"%_CP_RKT%subinacl" /outputlog=xpro.txt /subdirectories "%SystemDrive%\Program Files\\" /display=sddl
rem			"%_CP_RKT%subinacl" /outputlog=xuse.txt /subdirectories "%SystemDrive%\Users\\" /display=sddl
			"%_CP_RKT%subinacl" /outputlog=XACL_SS.TXT /stringreplaceonoutput=" %SystemDrive%\Windows\ServiceProfiles\LocalService\AppData\LocalLow\Microsoft\\"=" " /nostatistic /subdirectories %SystemDrive%\Windows\ServiceProfiles\LocalService\AppData\LocalLow\Microsoft\ /display=sddl
rem:			"%_CP_RKT%subinacl" /outputlog=XACL_SS.TXT            /stringreplaceonoutput=" C:\Windows\ServiceProfiles\LocalService\AppData\LocalLow\Microsoft\\"=" " /nostatistic /subdirectories            C:\Windows\ServiceProfiles\LocalService\AppData\LocalLow\Microsoft\ /display=sddl
			if errorlevel 1 goto abort
rem		) else (
rem			icacls "%SystemDrive%\Windows" /save xwin.txt /T /L
rem			icacls "%SystemDrive%\Program Files" /save xpro.txt /T /L
rem			icacls "%SystemDrive%\Users" /save xuse.txt /T /L
			forfiles /P "%SystemDrive%\Windows\ServiceProfiles\LocalService\AppData\LocalLow\Microsoft" /S /C "cmd /U /C if not @file==\"$\" icacls @path /save %%~fi\$ /L & echo.>> %%~fi\$& copy /b %%~fi\XACL_IS.TXT+%%~fi\$ %%~fi\XACL_IS.TXT" > nul
rem:			forfiles /P            "C:\Windows\ServiceProfiles\LocalService\AppData\LocalLow\Microsoft" /S /C "cmd /U /C if not @file==\"$\" icacls @path /save %%~fi\$ /L & echo.>> %%~fi\$& copy /b %%~fi\XACL_IS.TXT+%%~fi\$ %%~fi\XACL_IS.TXT" > nul
			if errorlevel 1 goto abort
			if exist $ del $
			if exist $ goto abort
rem		)
	)

:: Reset/Set Attr. for DIR./FILE
	attrib -R -H -S -A -I *_0* /S /D /L
	attrib +R +H +S +A +I *_1* /S /D /L
:BUG: Creation Time not copied for FILE of READONLY (copied for DIR.) with WinFM2008
:	attrib -R -H -S       *_1* /S /D /L
:	attrib    +H +S       *_1* /S /D /L

:: Check for SRC: \X0
	popd
	if .%_CP_FSN%==.NTFS for /D %%i in (\X0) do if exist %%i\ (
		for %%j in (4MB_1 4MB_1H 4MB_1L 1KB_1 1KB_1H 1KB_1L) do (
			echo %%i\%%j.TXT:
			fsutil sparse queryflag  %%i\%%j.TXT
			fsutil sparse queryrange %%i\%%j.TXT
		)
	)

	if .%_CP_FSN%==.NTFS for /D %%i in (\X0) do if exist %%i\ (
		compact /A %%i\*
	)

	if .%_CP_FSN%==.NTFS for /D %%i in (\X0) do if exist %%i\ (
		for %%j in (4MB_0 1KB_0 4MB_1 1KB_1) do (
			echo Hard Links of %%i\%%j.TXT:
			fsutil hardlink list %%i\%%j.TXT
		)
	)

	if .%_CP_FSN%==.NTFS for /D %%i in (\X0) do if exist %%i\ (
rem		dir /A /R %%i
		lads %%i
	)

	if exist \X0\ (
		echo Check entries in "\X0"
		start \X0
	)
	echo Done: %~n0
	goto exit

:test
	echo Copy Test for Backup/Copy Softwares ===========================================

:: Disable Very Long Paths over 260 char.
	ren \X0\0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcde 0
	if errorlevel 1 goto abort

:: Copy Test without Very Long Paths over 260 char.
:	if exist \X1\ call xcp -frc -rob -c  \X1 \X0
	if exist \X2\ call xcp -frc -ric -c  \X2 \X0
:	if exist \X3\ call xcp -frc -fc2 -c  \X3 \X0
:	if exist \X4\ call xcp -frc -ffc -c  \X4 \X0
	if exist \X5\ call xcp -frc -fv6 -c  \X5 \X0
:	if exist \X6\ call xcp -frc -wfm -c  \X6 \X0
:	if exist \X7\ call xcp -frc -far -c  \X7 \X0

:: Enable Very Long Paths over 260 char.
	ren \X0\0 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcde
	if errorlevel 1 goto abort

:: Copy Test with Very Long Paths over 260 char.
:: Error with RichCopy (-ric) and FileVisor6 (-fv6)
	if exist \X1\ call xcp -frc -rob -c  \X1 \X0
:	if exist \X2\ call xcp -frc -ric -c  \X2 \X0
	if exist \X3\ call xcp -frc -fc2 -c  \X3 \X0
	if exist \X4\ call xcp -frc -ffc -c  \X4 \X0
:	if exist \X5\ call xcp -frc -fv6 -c  \X5 \X0
	if exist \X6\ call xcp -frc -wfm -c  \X6 \X0
	if exist \X7\ call xcp -frc -far -c  \X7 \X0

:: Save order of DIR. entries (FAT32/FAT)
	pushd .
	if not .%_CP_FSN%==.NTFS for /D %%i in (\X1 \X2 \X3 \X4 \X5 \X6 \X7) do if exist %%i\ (
		cd %%i
		if errorlevel 1 goto abort
		forfiles > XODE.TXT
	)

:: Save Access Control Lists
	if .%_CP_FSN%==.NTFS for /D %%i in (\X1 \X2 \X3 \X4 \X5 \X6 \X7) do if exist %%i\ (
		cd %%i
		if errorlevel 1 goto abort
		if exist Microsoft\ rd /S /Q Microsoft
		if exist Microsoft\ goto abort
		copy nul XACL_SG.TXT > nul
		copy nul XACL_IG.TXT > nul
		copy nul XACL_SS.TXT > nul
		copy nul XACL_IS.TXT > nul

rem		if exist "%_CP_RKT%subinacl.exe" (
			"%_CP_RKT%subinacl" /outputlog=XACL_SG.TXT /stringreplaceonoutput=" %%~fi\\"=" " /nostatistic /file * /display=sddl
			if errorlevel 1 goto abort
rem		) else (
			forfiles /C "cmd /U /C if not @file==\"$\" icacls @file /save $ /L & echo.>> $& copy /b XACL_IG.TXT+$ XACL_IG.TXT" > nul
			if errorlevel 1 goto abort
			if exist $ del $
			if exist $ goto abort
rem		)
	)
	popd
	if .%_CP_FSN%==.NTFS for /D %%i in (\X1 \X2 \X3 \X4 \X5 \X6 \X7) do if exist %%i\ (
rem BUG?: icacls: "S:AINO_ACCESS_CONTROL" may be set with Robocopy (-rob)
		if %%i==\X1 call xcp -frc -rob -c  %%i %SystemDrive%\Windows\ServiceProfiles\LocalService\AppData\LocalLow
rem		if %%i==\X1 call xcp -frc -rob -c  %%i            C:\Windows\ServiceProfiles\LocalService\AppData\LocalLow
		if %%i==\X2 call xcp -frc -ric -c  %%i %SystemDrive%\Windows\ServiceProfiles\LocalService\AppData\LocalLow
rem:		if %%i==\X2 call xcp -frc -ric -c  %%i            C:\Windows\ServiceProfiles\LocalService\AppData\LocalLow
		if %%i==\X3 call xcp -frc -fc2 -c  %%i %SystemDrive%\Windows\ServiceProfiles\LocalService\AppData\LocalLow
rem:		if %%i==\X3 call xcp -frc -fc2 -c  %%i            C:\Windows\ServiceProfiles\LocalService\AppData\LocalLow
		if %%i==\X4 call xcp -frc -ffc -c  %%i %SystemDrive%\Windows\ServiceProfiles\LocalService\AppData\LocalLow
rem:		if %%i==\X4 call xcp -frc -ffc -c  %%i            C:\Windows\ServiceProfiles\LocalService\AppData\LocalLow
		if %%i==\X5 call xcp -frc -fv6 -c  %%i %SystemDrive%\Windows\ServiceProfiles\LocalService\AppData\LocalLow
rem:		if %%i==\X5 call xcp -frc -fv6 -c  %%i            C:\Windows\ServiceProfiles\LocalService\AppData\LocalLow
		if %%i==\X6 call xcp -frc -wfm -c  %%i %SystemDrive%\Windows\ServiceProfiles\LocalService\AppData\LocalLow
rem:		if %%i==\X6 call xcp -frc -wfm -c  %%i            C:\Windows\ServiceProfiles\LocalService\AppData\LocalLow
		if %%i==\X7 call xcp -frc -far -c  %%i %SystemDrive%\Windows\ServiceProfiles\LocalService\AppData\LocalLow
rem:		if %%i==\X7 call xcp -frc -far -c  %%i            C:\Windows\ServiceProfiles\LocalService\AppData\LocalLow

		if exist %%i\Microsoft\ (
rem			if exist "%_CP_RKT%subinacl.exe" (
				"%_CP_RKT%subinacl" /outputlog=%%~fi\XACL_SS.TXT /stringreplaceonoutput=" %%~fi\Microsoft\\"=" " /nostatistic /subdirectories %%~fi\Microsoft\ /display=sddl
				if errorlevel 1 goto abort
rem			) else (
				forfiles /P "%%i\Microsoft" /S /C "cmd /U /C if not @file==\"$\" icacls @path /save %%~fi\$ /L & echo.>> %%~fi\$& copy /b %%~fi\XACL_IS.TXT+%%~fi\$ %%~fi\XACL_IS.TXT" > nul
				if errorlevel 1 goto abort
				if exist %%i\$ del %%i\$
				if exist %%i\$ goto abort
rem			)
		)
		if not exist %%i\Microsoft\ md %%i\Microsoft
		if not exist %%i\Microsoft\ goto abort
	)

:: Check for DST: \X1 .. \X7
	if exist XODE.log del XODE.log
	if exist XODE.log goto abort
	if not .%_CP_FSN%==.NTFS echo Check order of DIR. entries (FAT32/FAT)> XODE.log
	if not .%_CP_FSN%==.NTFS for /D %%i in (\X1 \X2 \X3 \X4 \X5 \X6 \X7) do if exist %%i\ (
		echo ------------------------------------------------------------------------------->> XODE.log
		fc \X0\XODE.TXT %%i\XODE.TXT >> XODE.log
	)
	if exist XODE.log (
		echo.
		echo Check "XODE.log"
		start XODE.log
	)

	if .%_CP_FSN%==.NTFS for /D %%i in (\X1 \X2 \X3 \X4 \X5 \X6 \X7) do if exist %%i\ (
		for %%j in (4MB_1 4MB_1H 4MB_1L 1KB_1 1KB_1H 1KB_1L) do (
			echo %%i\%%j.TXT:
			fsutil sparse queryflag  %%i\%%j.TXT
rem			fsutil sparse queryrange %%i\%%j.TXT
		)
	)

	if .%_CP_FSN%==.NTFS for /D %%i in (\X1 \X2 \X3 \X4 \X5 \X6 \X7) do if exist %%i\ (
		compact /A %%i\*
	)

	if .%_CP_FSN%==.NTFS for /D %%i in (\X1 \X2 \X3 \X4 \X5 \X6 \X7) do if exist %%i\ (
		for %%j in (4MB_0 1KB_0 4MB_1 1KB_1) do (
			echo Hard Links of %%i\%%j.TXT:
			fsutil hardlink list %%i\%%j.TXT
		)
	)

	if exist XACL_SG.log del XACL_SG.log
	if exist XACL_SG.log goto abort
	if .%_CP_FSN%==.NTFS for %%i in (\X0\XACL_SG.TXT) do if 0%%~zi GTR 0 (
		echo Check DACL etc. with subinacl for granted ACL> XACL_SG.log
		for /D %%j in (\X1 \X2 \X3 \X4 \X5 \X6 \X7) do if exist %%j\ (
			echo ------------------------------------------------------------------------------->> XACL_SG.log
			fc /U \X0\XACL_SG.TXT %%j\XACL_SG.TXT >> XACL_SG.log 2>>&1
		)
		echo.
		echo Check "XACL_SG.log"
		start XACL_SG.log
	)

	if exist XACL_IG.log del XACL_IG.log
	if exist XACL_IG.log goto abort
	if .%_CP_FSN%==.NTFS for %%i in (\X0\XACL_IG.TXT) do if 0%%~zi GTR 0 (
		echo Check DACL etc. with icacls for granted ACL> XACL_IG.log
		for /D %%j in (\X1 \X2 \X3 \X4 \X5 \X6 \X7) do if exist %%j\ (
			echo ------------------------------------------------------------------------------->> XACL_IG.log
			fc /U \X0\XACL_IG.TXT %%j\XACL_IG.TXT >> XACL_IG.log 2>>&1
		)
		echo.
		echo Check "XACL_IG.log"
		start XACL_IG.log
	)

	if exist XACL_SS.log del XACL_SS.log
	if exist XACL_SS.log goto abort
	if .%_CP_FSN%==.NTFS for %%i in (\X0\XACL_SS.TXT) do if 0%%~zi GTR 0 (
		echo Check Owner, Group and SACL etc. with subinacl for system> XACL_SS.log
		for /D %%j in (\X1 \X2 \X3 \X4 \X5 \X6 \X7) do if exist %%j\ (
			echo ------------------------------------------------------------------------------->> XACL_SS.log
			fc /U \X0\XACL_SS.TXT %%j\XACL_SS.TXT >> XACL_SS.log 2>>&1
		)
		echo.
		echo Check "XACL_SS.log"
		start XACL_SS.log
	)

	if exist XACL_IS.log del XACL_IS.log
	if exist XACL_IS.log goto abort
	if .%_CP_FSN%==.NTFS for %%i in (\X0\XACL_IS.TXT) do if 0%%~zi GTR 0 (
		echo Check Owner, Group and SACL etc. with icacls for system> XACL_IS.log
		for /D %%j in (\X1 \X2 \X3 \X4 \X5 \X6 \X7) do if exist %%j\ (
			echo ------------------------------------------------------------------------------->> XACL_IS.log
			fc /U \X0\XACL_IS.TXT %%j\XACL_IS.TXT >> XACL_IS.log 2>>&1
		)
		echo.
		echo Check "XACL_IS.log"
		start XACL_IS.log
	)

	if .%_CP_FSN%==.NTFS for /D %%i in (\X1 \X2 \X3 \X4 \X5 \X6 \X7) do if exist %%i\ (
rem		dir /A /R %%i
		lads %%i
	)

	for /D %%i in (\X7 \X6 \X5 \X4 \X3 \X2 \X1) do if exist %%i\ (
		start %%i
		timeout /T 1 /NOBREAK > nul
	)
	if exist \X1\ echo DIR./FILE copied from \X0 to \X1 with Robocopy
	if exist \X2\ echo DIR./FILE copied from \X0 to \X2 with RichCopy
	if exist \X3\ echo DIR./FILE copied from \X0 to \X3 with FastCopy
	if exist \X4\ echo DIR./FILE copied from \X0 to \X4 with Fire File Copy
	if exist \X5\ echo DIR./FILE copied from \X0 to \X5 with FileVisor6
	if exist \X6\ echo DIR./FILE copied from \X0 to \X6 with WinFM2008
	if exist \X7\ echo DIR./FILE copied from \X0 to \X7 with Far Manager
	echo Check Very Long Paths, Links of Reparse Points, Time Stamps and Attributes etc.
	echo Done: %~n0
	goto exit

:abort
	echo.
	echo Aborted: %~n0
:exit
	set _CP_FSN=
	set _CP_RKT=
	set _CP_MAN=
	pause
:end
/* Copyright: Public Domain (free contents) for the inside of this border. */
/* Everyone can copy, revise and distribute/publish the contents in the inside of this border. */