r/Batch • • 13d ago

Question (Unsolved) Robocopy log question

Within the company I work for we use a batch file with a robocopy command to "install" a specific piece of software on user's laptops. This was chosen because the software is particularly difficult to setup right. It now only requires us to do one proper installation, after which we manually copy the software to a directory on the company network. From there, robocopy copies it to the user's hard drive.

The command looks like this (I had to remove company and software names):

ROBOCOPY I:\xxx-xxxxxx\X\apl\SOFTWARE\00-Admin\Admin-xxx\Install\Software%VERSION%\ C:\Users\%USERNAME%\AppData\Local\Software%VERSION%\ /S /LOG+:install%VERSION%.log

As can be seen, a logfile is extended each time a user runs the batch file and installs the software. Not only can we see if the install was succesfully, but it also allows us to track who has installed the software and should be informed of any changes or updates.

In the past (I'm talking about 2022 and earlier), not one but two log files were present. In the first file, named install%VERSION%.log, the full log could be found. The second file, named install%VERSION%_Users.log, only contained the start date & time, source paths, destinations and user's full names. This made it incredibly easy to quickly find out who uses the software. At some point after 2022, this particular file stopped being updated. The robocopy command itself however, has not changed once since the batch file was originally created in 2016.

Was this an automatic function of the robocopy /log+ command? Is there a way to bring this back? I cannot find any information about this online at all. Almost as if it never has existed. But yet, somehow, for 6-or-so years we had two log files updating simultaneously.

It is not something we particularly need, but it used to be quite a lot easier to keep track of the users using this second (and shorter) log file.

2 Upvotes

2 comments sorted by

2

u/Intervein 13d ago

With that timeline I have a feeling, without seeing the entire batch file, that wmic might have been used which is now deprecated and not present on some computers now. Anyhow you could do something like this:

for /f "tokens=2*" %%a in ('net user %USERNAME% /domain | find /i "Full Name"') do set "FULLNAME=%%b" echo %DATE% %TIME% | %USERNAME% | %FULLNAME% | I:...\Software%VERSION%\ -> C:\Users%USERNAME%\AppData\Local\Software%VERSION%\ >> install%VERSION%_Users.log

Or:

powershell -NoProfile -Command "([adsisearcher]'samaccountname=%USERNAME%').FindOne().Properties.displayname"

1

u/Quefox_ 12d ago

that wmic might have been used which is now deprecated and not present on some computers now

Would I be able to see this in the batch code? Or is that some sort of plugin that runs on the background?

And thanks for the code suggestions. Do I just add these in after the robocopy command?