Link to home
Start Free TrialLog in
Avatar of hdhondt
hdhondtFlag for Australia

asked on

COPY command does not work if run as administrator

I have a batch file which I use for my backup. It runs with administrative privileges. It works fine, except for the last command:

copy /y "D:\HDDocuments\PWSafe\test.psafe3" n:\

Open in new window


This should copy 1 file to a network drive. However, when it tries to execute this, the batch file returns the error "The system cannot find the path specified". If I copy the command line and paste it into a CMD window it runs fine, except if I run CMD as administrator. Conversely, if I do not run the batch file as administrator, the command also executes fine, but then the rest of the batch file fails as it cannot access all files needed.

All other commands in the batch file use ROBOCOPY, and copy to a USB drive, not to a network drive. The network drive is a flash drive that is plugged into my router (TP-Link Archer D5) so it is always visible to other WiFi devices. The PC is hardwired into the router.

Why is it that the same command works if executed as a normal user, but not as administrator?
ASKER CERTIFIED SOLUTION
Avatar of Pierre Bengtsson
Pierre Bengtsson
Flag of Sweden image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of McKnife
Don't use n:, but use the UNC path that is behind n:
Avatar of Hello There
Hello There

Specify the UNC path.
Avatar of hdhondt

ASKER

Using the UNC path did the trick. Thanks everyone. As Pierre was first he gets the points.