xcopy and unc routes

Bardobrave
Bardobrave used Ask the Experts™
on
Hi experts.

I'm facing some sort of strange behaviour using xcopy to move files in our network (client machines are windows 7, server is windows 2008 R2).

On an Access application I have an option to load files from client machines to a server drive. This drive has a folder where documents are stored where Access App's users have permissions, however, they haven't on the ancestors folders.

I use xcopy to move files within the Access app and it works perfectly from my windows user (as I have full access to all the path) but from client computers with other users xcopy returns an invalid drive error.

So:
xcopy "c:/myDirectoryWhatever/coolFile.pdf" "\\networkDrive\networkShare\saveToThisFolder\" /R /Y

Works from users with permissions on the full path but not on users with permissions only on saveToThisFolder.

However, if I use:
xcopy "c:/myDirectoryWhatever/coolFile.pdf" "z:\saveToThisFolder\" /R /Y

being Z a network drive built on logon on client machines it works ok.

Why don't change it on Access code? Easy... if I hardcode that drive letter we can find on the future that a change on logon scripts will blindly screw this code. Also a network drive could fail to load on logon due to network connection issues although later that issues solve, on that cases the share would be accesible but the network drive not.

Obviously give permissions on the ancestors of saveToThisFolder is not an option, as it has more folder inside where users shouldn't have access.

With all this in mind I wonder if there's some way to fix the copy of the files without having to use the network drives.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
you can do the mapping in VBA and delete the mapping after the copy

Author

Commented:
And what about if a change on the logon scripts (that are out of my reach) maps a determinate unit letter and I'm using that unit letter for the mapping? It will produce a conflict and the system will fail.

And today that unit IS mapped on the client machines, so if I try to remap it will also fail...

Commented:
there is a syntax for chekcing available drive letters...
Ok, I've finally solved it by myself.

I've changed the call to xcopy with a call to copy.

At the beginning I discarded copy because it couldn't be called from within Access vba using WScript.Shell (copy is inside command.com I think?)

However I've found a way to call it by doing:
cmd /C copy "sourcePath" "destinationPath" /Y

Now UNC paths works ok disregards of user permissions on destination folder ancestors.

Author

Commented:
I solved it by myself

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial