Robocopy switch /A-:SH

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15716
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Robocopy switch /A-:SH

Post by ChrisGreaves »

In recent months I have been plagued by RoboCopy hiding my files; a workaround for me was ATTRIB –S –HJ –R /S /D
I found a solution on the web.
The switch

Code: Select all

/A-:SH
solves the problem; said by some to be a bug.

Code: Select all

robocopy t:\      y:\%computername% /s /r:0 /w:0 /XJ /MIR /A-:SH
Cheers
Chris
You do not have the required permissions to view the files attached to this post.
By definition, educating the client is the consultant’s first objective

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15716
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: Robocopy switch /A-:SH

Post by ChrisGreaves »

I find it hard to believe that I have lived with this for four years. I recently was persuaded to look closer at this problem of the attribute bits.
This page says “ … I found out that Robocopy has a bug where it alters the attributes of the directory to a system and hidden file. It's been known for quite some time …”
This page says “ … RoboCopy may set the new directory to hidden, as it copies the system attribute of the root folder of the drive over to the new folder. …”.
Two types of solution are offered:-
(1) Use the “/A-:SH” parameter on the command line
(2) Do an ATTRIBute pass after the backup is made “start /B /WAIT attrib -s -h -r /s /d”
That I did not report back after March 2020 might suggests that the first suggestion worked.
Since then I have moved through Win10, Win11, and back to Win7, and the problem persists.

Two days ago I reasoned that:-
(a) the batch file I use for making nightly backups had not changed
(b) the problem persisted through three different versions of Windows and
(c) I had made no changes to dear old ReboCopy.EXE

Perhaps I had multiple copies of RoboCopy and one of them had the bug, and that was the version I had switched to.
1.png
Well, I have three versions of RoboCopy on my data drive; I may have even more on my weekly accumulative backup drive.
Two nights ago I inserted code to use a specific version of Robocopy in the batch file:-

Code: Select all

set ROBOCOPY="T:\Appl\UTIL\RoboCopy.exe"
set ROBOCOPY="C:\Windows\SysWOW64\RoboCopy.exe"
set ROBOCOPY="C:\Windows\System32\RoboCopy.exe"
and:-

Code: Select all

%robocopy% t:\      y:\%computername% /s /r:0 /w:0  /A-:SH /log:%LoggingFile%
2.png
I have run the modified backup file for two nights now, and the folders on the backup drive appear before and after the backup.
I am feeling quite happy with my sleuthing.

If the bug is in RoboCopy then maybe an earlier version of RoboCopy does NOT have the bug.

I use Robocopy quite simply – indeed, only for backups and restoring a data drive from a backup, so the 125KB version is fine for me.
Perhaps I was initially using the 78K version, then switched to the 97KB version (with the bug), and am now up to date with the 125KB in which the bug is fixed.
Moral: Hang on to old versions of software and fall back (or in my case forwards) to avoid the bug.
Cheers, Chris
You do not have the required permissions to view the files attached to this post.
By definition, educating the client is the consultant’s first objective

User avatar
John Gray
PlatinumLounger
Posts: 5437
Joined: 24 Jan 2010, 08:33
Location: A cathedral city in England

Re: Robocopy switch /A-:SH

Post by John Gray »

My up-to-date Windows 10 has ROBOCOPY.EXE in \Windows\System32 at 172,544 bytes.
I use it every day for backups, and haven't notice any System/Hidden problem.
John Gray

If you are having problems with solitude, you are not alone.

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15716
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: Robocopy switch /A-:SH

Post by ChrisGreaves »

John Gray wrote:
07 Jun 2024, 08:51
My up-to-date Windows 10 has ROBOCOPY.EXE in \Windows\System32 at 172,544 bytes.
I use it every day for backups, and haven't notice any System/Hidden problem.
Thanks John. I have used RoboCopy for about 20 years. Only in the past five years or so have I had problems.

I suspect that the problems arise from a specific combination of Windows O/S program code AND RoboCopy program code.

Apparently in a recent (4 years?) re-installation I moved away from one version of RoboCopy to another version of RoboCopy, a change which dropped me in that awkward combination.

Three days ago I moved back to the latest version of RoboCopy of the three on my system, and that seems to have dislodged the problem.

I confess that I am a fair target for "Chris! You should always use the latest version", but my [re]installation procedure is a list of steps to take, so most likely I just followed the steps to the - then - earlier "most recent" RoboCopy.

Your comment suggests that your version arrived WITH Win10, whereas I started with something called RKTools.exe

The Wikipedia page on Robocopy appears to list 6.1.7601 as the most recent version (2009) but this cannot be so.
This Microsoft page tells us to go to this page where we see several versions, none of which is listed as 175,xxx bytes.

There are web pages for downloading version of RKTools.exe

Right now the backup appears to be working again without the need for a two-minute sweep with ATTRIB; but if a public newer version of Robocopy appears I shall experiment with it.

I am left with the following two points:-
(1) Holding on to several versions of a utility application can be a handy way of determining where a problem lies and
(2) Writing batch or script files that can easily be switched between different versions of a utility application is a useful trick.

Cheers, Chris
By definition, educating the client is the consultant’s first objective

User avatar
John Gray
PlatinumLounger
Posts: 5437
Joined: 24 Jan 2010, 08:33
Location: A cathedral city in England

Re: Robocopy switch /A-:SH

Post by John Gray »

My files version shows as 10.0.19401.4355 from 15/05/2024.
I imagine some update or other caused it?

If you look at the box to the top right of that Wikipedia page they list a Windows 11 23H2 version which is more recent than the one you quote from the bottom of the Wikipedia page.
John Gray

If you are having problems with solitude, you are not alone.

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15716
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: Robocopy switch /A-:SH

Post by ChrisGreaves »

John Gray wrote:
07 Jun 2024, 13:19
If you look at the box to the top right of that Wikipedia page they list a Windows 11 23H2 version ...
Thank you John.
I think that there are two streams of RoboCopy.exe:-
(1) The original stream that came to us as part of RKTools.exe and
(2) A newer stream that supplies RoboCopy.exe as part of Win10/Win11.

I am not at all sure about this.

I think that anyone anywhere could download a copy of RKTools.EXE and extract/make use of the RoboCopy.exe within.
I think that the more recent versions of RoboCopy.exe will be available to users ONLY if they have installed Win10/11.

I can check this out next time I fire up my Win11 system.
Cheers, Chris
By definition, educating the client is the consultant’s first objective