Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,
I'm very new to writing batch files.
I've written a very simple .cmd file to make a couple directories and copy some files into them. This file is used on many different computers to install some templates.
It usually works just fine, but about 25% of the time, it creates the paths, but does not copy the files. I put several pause commands in it but it does not pause at them on the problem computers. (The DOS window opens and the commands quickly run by.)
Am I missing something obvious? Why would it work on "most" machines?
The batch file is below -- I originally had double quotes around all file names and paths, but took them off of the ones that don't contain spaces in case that was wrong. It didn't make a difference.
BATCH FILE:
rem make directories
@echo ON
md C:\ABC.docs\listsrem copy templates
copy Pleading.dot "C:\Documents and Settings\%username%\My Documents\Word templates\Pleading.dot" /ycopy PleadingFormRogs.dot "C:\Documents and Settings\%username%\My Documents\Word Templates\PleadingFormRogs.dot" /y
copy "Proof of Service.dot" "C:\Documents and Settings\%username%\My Documents\Word Templates\Proof of Service.dot" /y
Pausecopy ABCStartup.dot "C:\Documents and Settings\%username%\Application Data\Microsoft\Word\STARTUP\ABCStartup.dot" /y
copy ABCNums.dot "C:\Documents and Settings\%username%\Application Data\Microsoft\Word\STARTUP\ABCNums.dot" /y
Pauserem copy database files
copy rogs.mdb "c:\ABC.docs\lists\rogs.mdb" /y
copy personnel.mdb "c:\ABC.docs\lists\personnel.mdb" /y
copy ABCNums.mdb "c:\ABC.docs\lists\ABCNums.mdb" /y
Pause
rem see if userNums exists, copy only if it's not there.if not exist c:\ABC.docs\lists\userNums.mdb goto copyit
Pause
exit
:copyit
copy userNums.mdb c:\ABC.docs\lists\userNums.mdb /-y
Pause
exitThanks so much for any help!
Laura

Hi Laura,
Since you're using different OSs, it's hard to pinpoiny.
I would start by putting back the doubl;e quotes on any path / filename which is not strictly DOS 8.3
Next, in DOS [or DOS based win] I don't think you can create a dir and a sub at once, so this:
md c:\abc\def
may need to be changed to:
md c:\abc
md c:\abc\defYou may want to REM out the EXIT until you get it troubleshot.
No idea why PAUSE does not work.
HTH
a
M2
If at first you don't succeed, you're about average.

Thanks for your reply.
I read somewhere on the internet that the copy command does not necessarily come out of the folder the batch file is in. It's the folder that the dos prompt is looking at (something like that).
So I'm wondering if that is my problem.
I could try the pushd and popd comands to get the current directory, except that some of these are being used from a network drive that is not mapped to a drive letter on the local machines, so I don't know if that would work.
If any of you know about this type of thing, I'd greatly appreciate the input.
Laura
Laura

Hi Laura,
I don't have a network to experiment with.
My instinct tells me that without mapping to a drive letter, this batch will be difficult at best.
M2
If at first you don't succeed, you're about average.

Hi Guy,
Well, at one client site the batch file is on a server drive that does not have a mapped letter. When I used it to install to some of their Windows XP computers, I had no problem. But when they've used it on their Windows 2000 machines it has created the path but not copied any files.
At another client site I used it on 5 computers from my data key that I plugged into a USB port -- and it worked great on all but one. The irony being that the one it didn't work on was the newest computer and I didn't pay attention but I'm assuming it therefore had a newer operating system.
I was wondering if I could use the PUSHD and POPD commands to tell it the current directory.
I can always insist on a path that I hard code into it, but it would be nice if it was a little more flexible/elegant.
Laura

Without knowing anything more about this, I can offer you a few suggestions to test for...
1. Permissions. If it's Windows 2000, is the person logged on as a local administrator?
2. Make sure the directory you are trying to copy to exists. There may not be a Templates folder under the %username%'s profile.
3. Copy /? in windows 2000, make sure the syntax is comparable to what you are using, Microsoft loves to take useful tools away from the command prompt. As well as changing the way others function.
4. Also try simplifying this a bit, there is no reason for having more than a few copy commands... Try this line instead:
copy *.dot "C:\Documents and Settings\%username%\My Documents\Word Templates\ /y >> log.txt
The log.txt file will list each file copied and then give a total like 8 files copied.
It may help to give you an indication of what's wrong.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |