What's new

Solved robocopy to Router USB Drive Issues

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

sne3zy

Occasional Visitor
Router: Asus GT-AX6000
PC: Windows 10 Home

I have a simple batch file that I want to mirror a directory on the same machine as the Windows task running the batch file, to a directory on a router attached USB drive. I have the same username on my Windows PC as a user on the router, but different passwords. I use "net use" to authenticate using the other credentials. I think I need to set a flag so that the credentials aren't stored permanently and only for each batch run, but that's a further development if I can get this to work once. The batch file is run under an administrator account on the PC, and the router user has read/write access to all directories. I can browse to the USB drive on the router just fine in Windows Explorer from multiple PCs on the LAN, each using a different router credentials. Read/write through Windows Explorer works as expected.

Here is the generalized code currently:

Code:
net use "\\router ip address\share" [router user password] /USER:[router username]
robocopy "C:\Users\username\local directory" "\\router ip address\share" /e /z /ZB /TBD /R:5 /W:5 /V /compress

After researching this, I added the extra flags other than the "/e", just for the sake of LAN efficiency, although this is not going to be running that frequently or too terribly large of files that it is actually needed. Regardless, the error is the same in any case.

net use error:
System error 53 has occurred.
The network path was not found.

robocopy error:
ERROR 67 (0x00000043) Getting File System Type of Destination \\router ip address\share\
The network name cannot be found.

Whether I used the device name or the IP address, the error was the same, until I ran it just before making this post and the net use error was different. I don't know what would have change with my network to get the different result when using the device name, the only difference in the code is "router ip address" is replaced with "devicename". Again, until today they both gave the net use error above. The robocopy error is the same in all cases.

net use error using device name:
System error 1219 has occurred.

Multiple connections to a server or shared resource by the same user, using more than one user name, are not allowed. Disconnect all previous connections to the server or shared resource and try again.
 
When you look at the share in Windows Explorer is the name something like "ASUS" or "ASUS (at ClickUSB)"? If it's the latter you need to use the complete name, e.g.

Code:
net use "\\192.168.1.1\ASUS (at ClickUSB)" mypassword /USER:admin
 
Is the router on the same subnet as the PC?
Do you really need password protection on the router share?
What is the brand and model of the router?
 
Yes, same subnet. Password protection since different router shares have different read/write permissions for different users.

Thanks for the quick replies. A combination of two things got this working. The new error about not having multiple connections to the same shared resource using multiple user names not being allowed forced me to try putting my PC's user password into the router's user, that already matched my PC's username. On doing this, net use was successful. That's not desirable, I'd like to have the batch file using credentials other than the current PC session username/password.

Using the full 'path' as shown in windows explorer got the robocopy working, including the parenthesis and "at USB drive" wording. The code now looks like this:

Code:
net use "\\router ip address\share (at USB_drive_volume_label)" [Windows user password] /USER:[Windows username]
robocopy "C:\Users\username\local directory" "\\router ip address\share (at USB_drive_volume_label)" /e /z /ZB /TBD /R:5 /W:5 /V /compress

But this makes the "net use" command unnecessary, since the router is on the same workgroup, and has a user with the same credentials. Robocopy would just work without any other commands.

I'll look into this multiple connections not allowed when using multiple usernames issue and reply with anything I find. Although I expect this is basic stuff, it might help someone doing a forum search in the future.
 
But this makes the "net use" command unnecessary, since the router is on the same workgroup, and has a user with the same credentials. Robocopy would just work without any other commands.
You should be able to specify a different username (I can), but Windows does have a habit of hanging on to old connections. This usually involves rebooting the PC to clear them. IIRC the maximum number of concurrent connections to the router's Samba server is 5.

If you were to use Merlin's firmware rather than stock you would have more options to customise the Samba configuration.
 
Thank you for the helpful information. In the end, not being able to use multiple usernames to the same shared resource seems to be a limitation you can't get around in Windows, at least in the Home editions. To get the correct credentials entered, you need to clear the old connection using "net use \\server\share /delete", before you can create a new connection with different credentials. I also added /SAVECRED to the net use command so that there isn't any issue with browsing in Windows explorer.

I don't need different credentials for the robocopy batch file or anything else hitting the router's USB drive, so I just cleaned the slate with a "net use * /delete" command and the batch runs as expected now. For any net use or shared resource newbies reading this, you could draft a batch that cleared the current connection, ran your code, then reconnected the shared resource. You could even have a mapped drive get remapped. This would only cause issues if the batch runs concurrently with another service or stream using the primary connection credentials.
 
Well if you have Windows 10 I would recommend you install Linux subsystem for Windows. From that Linux environment, generate an SSH key and paste it into the ssh section. Then use scp to copy from the SSD in the format
scp -r -P "ssh port" "routerLoginName"@"router IP":/tmp/mnt/"label given USB"/"folder name"/*.* (space)
/mnt/"drive letter"/"foldername"

Fill in the quoted areas with your specific data. You can set up a cron job in the Windows Linux environment to run on a schedule, or I'm sure there is a way to script PowerShell to call the Windows Subsystem for Linux (WSL) as a Windows scheduled task.
 
Last edited:

Similar threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top