View Full Version : Problem Batch File
06-12-2008, 02:54 PM
Hi All. I have a small batch file which I have used for years to back up folders from within the My Documents folder on C: to a folder on a separate drive, F:. The folders contain Word files, Excel files and Publisher files. I also use the same batch file to 'xcopy' other data files across to the F: drive using Scheduled Tasks.
The problem is that suddenly the batch file refuses to copy the Word, Excel and Publisher folders to F:, the batch file starts as expected then does not copy the afore mentioned folders but continues to copy all the non-Microsoft folders I have listed in the batch file. I have tried rewriting the batch file but to no avail. I have also amended and renamed the batch file to copy the folders from F: to H: and that seems to work OK. It seems that the batch file is somehow locked out of the My Documents folder, but then proceeds to copy everything else. Anyone any clues?
06-12-2008, 03:18 PM
Permissions on the files?
Spaces in filenames? (Enclose paths in quotes if so)
06-12-2008, 03:57 PM
Hi Mike. I didn't make myself clear, I'm copying the folders not the individual files and some of the lines in the batch file are as follows:
xcopy c:\docume~1\john\mydocu~1\jpjdocus f:\docsbak /d:01/09/2002 /s /v /y
xcopy c:\docume~1\john\mydocu~1\pubdocs f:\pubbak /d:01/09/2002 /s /v /y
The file worked for over 10 years and appeared to stop working on or about 19 April this year with no alterations by me.
P.S. I don't remember what the switches stand for in the above lines as they were originally composed by a friend who was well into PCs at that time
06-12-2008, 04:31 PM
Hmm, you really shouldn't use msdos long file name aliases in Windows 2000/XP. Perhaps they got broken or changed.
See if it works with the real paths, enclosed in quotes like:
xcopy "c:\documents and settings\john\my documents\jpjdocus" f:\docsbak /d:01/09/2002 /s /v /y
Another thing related to permissions, you are doing this as the user that owns the directories and files (john), yes?
06-13-2008, 03:00 PM
Thanks for your response. Yes I am logged in as user 'John' and have tried the batch file without the aliases, but no joy. However, managed to pause batch file just after it started and against the line to copy 'JPJ Docus' it says Access Denied. So it looks like a permissions problem.
I use Spybot and installed the latest version around the time this problem started - could this be the cause ? How would I grant the necessary permissions?
06-13-2008, 03:52 PM
I can't see how Spybot Search and Destroy would cause this.
Is this Windows XP Home Edition, Windows XP Professional, or Windows 2000? If Windows XP Home Edition, you would have to boot to Safe Mode to access the Security tab when you right click and view Properties.
Using that method, you can go to the Security tab and ensure that your user, or the administrators group has full control of the directory. (checkboxes). You can also ensure that john has ownership by clicking Advanced and going to the Owner tab.
A relatively easy way, that should work in all versions is to use the cacls command. You could do something like:
Open a command prompt. By default, you should be at c:\documents and settings\john
cacls "My Documents" /E /T /C /G "Administrators":F
With quotes as shown. (note that you don't really need the quotes around Administrators because there's no spaces in that group name)
This should grant Administrators (of which john is a member) full access. Unless the folder has been made "private" this is the default anyways. The /C switch continues even on access denied messages (e.g. if a file is in use or something it doesn't abort the rest of the operation)
It works with groups or specific usernames
Another reason you might get access denied messages is if a file is in use and protected by Windows. Hmm, maybe Spybot did do something like that though at the moment I can't forsee what file it could be in My Documents.
06-13-2008, 04:33 PM
Thanks Mike, I'll give that a try and let you know what happens
06-14-2008, 03:38 AM
Have run the cacls command and still no joy - access denied
06-14-2008, 12:52 PM
Well, you're going to have to find out what is causing the Access Denied message. Try running cacls on the directory with no arguments to display the permissions:
cacls "My Documents"
Also, who is to say that the problem is at that level. It might be in the directory above, for example, Documents and Settings\john
Also, could it be the destination that's causing the Access Denied message? You say you copy other folders, do they go to the same destination, f:\docsbak?
06-14-2008, 02:43 PM
I have run cacls on the directory with no arguments and don't understand results. It lists:
Write_dac -- and many more!
The batch file does copy other folders other than jpjdocus and sends them to different folders on F.
Whilst trying to sort out this problem I have installed Karen's Replicator program and that seems to doing the job of backing up my folders without any problem
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.