Batch file path problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to copy an Ms Access yadayada.mdb file to the "My Documents"
folder of a user and cannot get this to execute:

copy W:\yadayada.mdb C:\Documents and Settings\Owner\My Documents\Access
Files\yadayada.mdb

I suspected that maybe the file path was an issue so I tried:
Copy W:\yadayada.mdb C:\yadayada.mdb and it works.

I tried short names:
copy W:\yadayada.mdb C:\Docume~1\Owner\My_Doc~1\Access~1\yadayada.mdb

and it fails as well.

What am I doing wrong?
Len
 
NTFS file system? Ensure that you have adequate permissions to write to their My Documents folder.

XP PRO: In Windows Explorer, go to Tools, Folder Options, View and uncheck Use Simple File Sharing. Now, when you right click on a drive, folder or file (on an NTFS partition) and select Properties, you'll see a Security tab. Here you can assign or deny permissions based on user name or user group membership.

XP Home: By default, you can only make files and folders under My Documents "private". This is done by right clicking a folder or file and selecting Properties, Sharing. To change the permissions on other folders, you need to boot the computer to Safe Mode and log in on the built in Administrator account. In this mode, you'll see the Security tab in Properties, and you can assign permissions based on user name or group membership.

HOW TO: Set, View, Change, or Remove File and Folder Permissions in Windows XP
http://support.microsoft.com/default.aspx?scid=kb;en-us;308418

HOW TO: Set, View, Change, or Remove Special Permissions for Files and Folders
http://support.microsoft.com/default.aspx?scid=kb;EN-US;308419

HOW TO: Disable Simplified Sharing and Password-Protect a Shared Folder in Windows XP
http://support.microsoft.com/default.aspx?scid=kb;EN-US;307874
 
I created the batch file while logged in on the user's computer, as the user
and placed it on the user's desktop. Does the batch file not inherit the
user's permissions? I can copy and paste the file but not using the bat file.
 
You need double quotes, there is a space in the path. OK, there are
actually two spaces.

Try

"C:\Documents and Settings\Owner\My Documents\Access Files\yadayada.mdb"

or

"%userprofile%\My Documents\Access Files\yadayada.mdb"

copy W:\yadayada.mdb "%userprofile%\My Documents\Access Files\yadayada.mdb"

--
Hope this helps. Let us know.

Wes
MS-MVP Windows Shell/User

In
 
No, it doesn't. Files run under the credentials and permissions of the user launching it.
 
Thank you Wesley, I got lost in the short name/Long name and forgot, "It's a
string". DOH!
My apologies to Doug for not explaining myself more clearly as I was trying
to create a shortcut on the user's computer for the user to use while logged
in as the user.

Enclosing the string in quotes resolved the problem in a .bat file. For my
edification though why aren't the quotes necessary in the command window
where I can type a long name path with spaces and it works but copy the same
line into notepad, save it as a .bat and it fails. Minds that need examining
want to know :-)
 
Back
Top