-1

I cannot for the life of me get the thing to run on a new user laptop setup I'm working on. I'm hoping someone can help. I have been trying to search forums and YouTube videos but would really benefit from having someone maybe help me with my script language/input. I even contacted the prior IT administrator and it didn't result in a full resolution. I'll start with the Robocopy command I've been trying to run in CMD or PowerShell as well as the conversation about this with the prior IT guy.

Here is what I have so far. I have tried with and without " " quotation marks for the file path directory. The most output error message I've gotten is: ERROR Invalid Parameter #3: "\locutionsrv1\Backups\kmcqueen_Backups"

robocopy "C:\Users\Kristi McQueen\" "Z:\\locutionsrv1\Backups\%kmcqueen%_Backups\" *.* /V /S /E /DCOPY:DA /COPY:DAT /Z /XJD /XA:SH /MT:8 /R:2 /W:15 > "C:\Users\Kristi McQueen\Desktop\externalbackup.log"

EDIT:

After running the corrected commands after the first comment, I do get the log file generated on the Desktop with this message in it:

2023/01/04 10:49:36 ERROR 123 (0x0000007B) Accessing Source Directory C:\Users\Kristi Test" \locutionsrv1\Backups\Kristi\ The filename, directory name, or volume label syntax is incorrect.

and then when I try running the commands with %USERNAME% instead of the actual user's name in PowerShell, this is the error message I get:

PS C:\Users\Kristi Test> robocopy "C:\Users\%username%\" "\\locutionsrv1\Backups\%USERNAME%_Backups\" *.* /V /S /S /DCOPY:DA /COPY:DAT /Z /XJD /XA:SH /MT:8 /R:2 /W:15 > "C:\Users\%USERNAME%\Desktop\externalbackup.log"
out-file : Could not find a part of the path 'C:\Users\%USERNAME%\Desktop\externalbackup.log'.
At line:1 char:1
+ robocopy "C:\Users\%username%\" "\\locutionsrv1\Backups\%USERNAME%_Ba ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OpenError: (:) [Out-File], DirectoryNotFoundException
    + FullyQualifiedErrorId : FileOpenFailure,Microsoft.PowerShell.Commands.OutFileCommand

This is unbelievably frustrating and confusing as I made sure these folders/files exist and there's no issue with Access or Permissions, right?

EDIT 2: 1/5/23:

This is SO FRUSTRATING! I want to pull my hair out! I got the following command to work, I think, sort of, for a minute: robocopy C:\Users\ \\locutionsrv1\Backups\%USERNAME%\ *.* /V /S /S /DCOPY:DA /COPY:DAT /Z /XJD /XA:SH /MT:8 /R:2 /W:15

However, now it's not working. And when I check the Destination folder on the server to see what was backed up, the folder is named %USERNAME% and not the actual user's name! And it won't generate a log file to the user's desktop as I originally intended.

I want to bang my head against a wall. Now even that command that WAS working no longer is. In CMD, I'm back to getting the: "ERROR : Invalid Parameter #3 : "Test" message.

And in PowerShell I get:

2023/01/05 14:19:04 ERROR 1326 (0x0000052E) Creating Destination Directory \locutionsrv1\Backups\ The user name or password is incorrect. PS C:\Windows\system32> robocopy "%userprofile%" "\locutionsrv1\Backups%USERNAME%_Backups" . /V /S /E /DCOPY:DA /COPY:DAT /Z /XJD /XA:SH /MT:8 /R:2 /W:15 > "%UserProfile%\Desktop\externalbackup.log" out-file : Could not find a part of the path 'C:\Windows\system32%UserProfile%\Desktop\externalbackup.log'. At line:1 char:1

  • robocopy "%userprofile%" "\locutionsrv1\Backups%USERNAME%_Backups" ...
  •   + CategoryInfo          : OpenError: (:) [Out-File], DirectoryNotFoundException
      + FullyQualifiedErrorId : FileOpenFailure,Microsoft.PowerShell.Commands.OutFileCommand
    
3
  • This forum is frustrating if you can't even add a comment to keep the thread going that's any longer than 500 or whatever characters
    – bigwheel
    Commented Jan 5, 2023 at 21:23
  • Calm down please. This isn't a forum. You, as the person asking the question, are expected to do most of your writing in the question itself, adding new info, etc, to make the question more and more.complete. Commented Jan 6, 2023 at 5:43
  • @music2myear thanks, so do you have any actual technical assistance input? Or did you just want to comment to invalidate my frustration with these commands?
    – bigwheel
    Commented Jan 6, 2023 at 22:22

1 Answer 1

2

It looks like you're getting confused by some syntax. You want robocopy "source" "destination" [options]

  • source and destination should be quoted if they have spaces. Don't put both in the same set of quotes

  • the percent symbols mean a variable name. there are some automatic ones like %username% or %userprofile%. Literally the word "username", don't put the user's name in there.

  • Drive letter vs network paths: a path to a local drive uses the format C:\. A network folder (UNC) path uses the format \\servername\foldername\. If you have a drive mapped to a network share, you just use the drive letter like Z:\. Do not use both like Z:\\servername\etc\

Try this instead as is - notice the username is nowhere in the command. I'm using %userprofile% to get the path to that folder:

robocopy "%userprofile%" "\\locutionsrv1\Backups\%USERNAME%_Backups\" *.* /V /S /E /DCOPY:DA /COPY:DAT /Z /XJD /XA:SH /MT:8 /R:2 /W:15 > "%UserProfile%\Desktop\externalbackup.log"

Make sure that the destination folder actually exists for the username.


In powershell, the variable format is different, "C:\Users\%USERNAME%\" becomes "C:\Users\$env:USERNAME\"

8
  • Thank you very much for your help. I'm still lost it seems :( The log file does get generated to the desktop (after running the command as you corrected above)... and the log file gives this message: 2023/01/04 10:49:36 ERROR 123 (0x0000007B) Accessing Source Directory C:\Users\Kristi Test" \locutionsrv1\Backups\Kristi\ The filename, directory name, or volume label syntax is incorrect.
    – bigwheel
    Commented Jan 4, 2023 at 17:55
  • robocopy "C:\Users\%username%\" "\\locutionsrv1\Backups\%USERNAME%_Backups\" . /V /S /S /DCOPY:DA /COPY:DAT /Z /XJD /XA:SH /MT:8 /R:2 /W:15 > "C:\Users\%USERNAME%\Desktop\externalbackup.log" out-file : Could not find a part of the path 'C:\Users\%USERNAME%\Desktop\externalbackup.log'. At line:1 char:1 + robocopy "C:\Users\%username%\" "\\locutionsrv1\Backups\%USERNAME%_Ba ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : OpenError: (:) [Out-File], DirectoryNotFoundException + FullyQualifiedErrorId : FileOpenFailure,Microsoft.PowerShell.Commands.OutFileCommand"
    – bigwheel
    Commented Jan 4, 2023 at 17:57
  • @bigwheel it looks like your user's profile folder doesn't match their username, like kmcqueen vs Kristi McQueen. Run echo %username% to check if the username matches the folder name, or use %USERPROFILE% variable instead like in my edited answer above
    – Cpt.Whale
    Commented Jan 4, 2023 at 19:05
  • OK the echo %username% command spits out: Kristi McQueen just as I thought was correct
    – bigwheel
    Commented Jan 5, 2023 at 21:27
  • 1
    @bigwheel 1) powershell is a different language, and uses a different format for variables (read the last sentence in my answer). Both can use robocopy, but they aren't the same. 2) just check if the folder paths are right by using dir (in CMD) like dir "\\servername\folder" and fill in different folders in the quotes to test with. 3 you say the logging failed, but it looks like you just left out the part that does that (the > symbol and log path). I think it'd be helpful for you to try and understand what each part of the command is doing: ss64.com/nt/robocopy.html
    – Cpt.Whale
    Commented Jan 5, 2023 at 22:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .