Computing.Net > Forums > Programming > Simple (I hope) batch file problem

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Simple (I hope) batch file problem

Reply to Message Icon

Name: Laura545
Date: May 12, 2005 at 15:25:47 Pacific
OS: varies
CPU/Ram: varies
Comment:

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\lists

rem copy templates
copy Pleading.dot "C:\Documents and Settings\%username%\My Documents\Word templates\Pleading.dot" /y

copy 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
Pause

copy 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
Pause

rem 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
exit

Thanks so much for any help!



Laura



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: May 13, 2005 at 00:50:16 Pacific
Reply:

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\def

You 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.


0

Response Number 2
Name: Laura545
Date: May 13, 2005 at 11:13:57 Pacific
Reply:

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


0

Response Number 3
Name: Mechanix2Go
Date: May 13, 2005 at 11:28:19 Pacific
Reply:

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.


0

Response Number 4
Name: Guy
Date: May 14, 2005 at 06:52:52 Pacific
Reply:

Is there a pattern about the 25% that fail?

Are copies on only certain OS's failing?

Guy


0

Response Number 5
Name: Laura545
Date: May 14, 2005 at 20:36:09 Pacific
Reply:

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


0

Related Posts

See More



Response Number 6
Name: Acyf
Date: June 1, 2005 at 07:44:49 Pacific
Reply:

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.


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Simple (I hope) batch file problem

Batch File Problems www.computing.net/answers/programming/batch-file-problems/13301.html

Win XP batch file problem www.computing.net/answers/programming/win-xp-batch-file-problem/11239.html

Windows 2000 >> Batch file Problem www.computing.net/answers/programming/windows-2000-batch-file-problem/13167.html