1.

Solve : Trying to batch copy a file into Program Files folder?

Answer»

Hello all. First post so PLEASE be gentle with me LOL
I have tried to find an answer to this but to no avail so am hoping you guys might be able to help me.
I am running WINDOWS XP SP2
I would like to be able make a batch file that will copy a file from a directory on a CD to a directory within C:\Program Files.
I believe the problem I have is that I can't seem to get around the Read only attribute of Progam files and it's sub folders.
I am new to this but find it very interesting and am keen to learn
Here is what I have so far that I know works.

XCOPY E:Test1\testfile.txt C:\ /Y

I can only go as far a the Root of the drive. Any folders I try and paste into further than C:\ don't work.
I have tried (at least I think I have) USING the attrib -r command but it doesn't seem to work for me.
Could one of you point me in the right direction please.
Kind Regards
Jimmy
What is the name of the directory in C:\Program Files?

let us suppose

(1) the target folder actually exists already
(2) its path is C:\Program Files\test1

You did know that a path or folder name that contains spaces needs to be enclosed in quotes, didn't you?

So how about this...

XCOPY E:Test1\testfile.txt "C:\Program Files\test1" /Y

Try it and report back...

Quote

I can't seem to get around the Read only attribute of Progam files and it's sub folders.

I have never heard of that before. Who told you that? Mine certainly is not read-only. How would programs ever get installed if that were true?






Thats Amazing! A little pair of quotes was my problem after all.
Many Many Thanks for helping me out. I didn't know that an existing directory had to be in quotes. Sorry but I am very much a learner.
As for the read only attrib point; I am right in thinking that when you right click on a file ot folder and select properties, if the read only box is coloured in, that means the attributes are set to read only? Is that not right then? I thought that was my problem.
Kind regards for helpjng me and I look forward to the next time I may need help.
Thank you
Jimmy
Quote from: Jamangie on July 08, 2007, 06:03:36 AM
I didn't know that an existing directory had to be in quotes.

A directory or folder or file name only has to be in quotes if it contains one or more spaces. However it is a GOOD habit to always use them.

Quote from: Jamangie on July 08, 2007, 06:03:36 AM
As for the read only attrib point; I am right in thinking that when you right click on a file ot folder and select properties, if the read only box is coloured in, that means the attributes are set to read only?


When you right click an ordinary folder (not a file) (not a system folder) in Windows Explorer, and look at the "Attributes" section at the bottom of the "property sheet" (as it is called) that appears, the "Read-only" box is filled with the highlight colour, in a pale shade. This happens whether or not the folder is read-only. If you click the check box, you can make it go clear, (not read only) or you can get a check (tick) to appear in it (read only). If you click "apply" or "OK", you would think that the folder would get its attribute changed accordingly. It doesn't. Right click the folder again, you see the colour.

This is normal Windows behaviour for folders. It is by design. (That's the way Microsoft designed things). You can't change this.

If you want to change a folder from read-only to read-write, or vice versa, you have to do it from the command line using the ATTRIB command

attrib +R "folder path\folder name" to make it read-only

attrib -R "folder path\folder name" to make it read-write.

Explanation here

http://support.microsoft.com/kb/326549

A Great Explanation. Many Thanks again. Speak soon
Jimmy


Discussion

No Comment Found