Link to home
Start Free TrialLog in
Avatar of RICHARDH
RICHARDH

asked on

Instal.bat question

I am writing an install file which will copy some files from a CD-ROM to a hard drive.

I can use a line such as...

copy d:\users.txt c:\champs\users.txt

But this only works if the user's CD is the 'D' drive. As the install program is being run from the CD is there a way of copying from the current drive to the C drive or a way of finding which drive the CD-ROM is in.

Thanks for the help
ASKER CERTIFIED SOLUTION
Avatar of robpitt
robpitt

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of RICHARDH
RICHARDH

ASKER

A problem I am afraid.

If I have a line such as

if exist D:\somefile.txt cd G:

If the drive with letter 'G' does not exist on the system then the Install.bat file stops with an error message.

Any suggestions.

Thanks for the help..
Richard.
A problem I am afraid.

If I have a line such as

if exist D:\somefile.txt cd G:

If the drive with letter 'G' does not exist on the system then the Install.bat file stops with an error message.

Any suggestions.

Thanks for the help..
Richard.
Actually I did make a minor mistake - to reiterate the "if" statements should be of the form :

  if exist X:\somefile.txt X:


That is ....


 rem -- First check current directory
 if exist somefile.txt goto doinstall

 rem -- now check drive letters DEFGHI and if found change drive
 if exist D:\somefile.txt D:
 if exist E:\somefile.txt E:
 if exist F:\somefile.txt F:
 if exist G:\somefile.txt G:
 if exist H:\somefile.txt H:
 if exist I:\somefile.txt I:
 cd \

 :doinstall
 copy users.txt c:\champs\users.txt


Which OS family?  NT/2K/XP, 9x/Me or DOS?

It's an OLD DOS trick

@echo off
copy %0\..\users.txt c:\champs\users.txt

try it and let me know :-)

regards
>> copy %0\..\users.txt c:\champs\users.txt

What happens if run from a nested subdirectory?

No problem; the shell uses it as follows:

Let's say %0 contains something like:

D:\SETUP\DISK1\INSTALL.BAT

when You use that syntax the "source dir" will be

D:\SETUP\DISK1\INSTALL.BAT\..\USERS.TXT

now the shell will follow the path and treat INSTALL.BAT ... as a SUBDIR so that

\setup\disk1\install.bat\..

will become

\setup\disk1

so ... You see it by Yourself

Give it a try and You'll see !

This trick comes straight from DOS 3.30 and MS mantained it for compatibility through each and every new O/S

Regards






Hey now that's a smart trick!
RICHARDH:

You have many open questions:

https://www.experts-exchange.com/jsp/qShow.jsp?qid=11342298
https://www.experts-exchange.com/jsp/qShow.jsp?qid=11355858
https://www.experts-exchange.com/jsp/qShow.jsp?qid=11382838
https://www.experts-exchange.com/jsp/qShow.jsp?qid=11415199
https://www.experts-exchange.com/jsp/qShow.jsp?qid=11670638
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20001107
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20004454
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20065368
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20073152
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20084825
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20084821
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20086663
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20086784
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20107892
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20109405
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20109357
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20109887
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20110886
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20117400
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20118020
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20118934
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20118648
https://www.experts-exchange.com/jsp/qShow.jsp?qid=11342618
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20130049
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20132692
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20142937
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20146293
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20147289
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20148615
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20149087
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20148609
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20150501
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20150630
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20154720
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20154865
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20154980
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20155947
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20180018
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20189434
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20193459
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20222409
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20235436
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20244279
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20244276
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20193051
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20256056
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20257136
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20257135
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20127746
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20259971
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20259964

To assist you in your cleanup, I'm providing the following guidelines:

1.  Stay active in your questions and provide feedback whenever possible. Likewise, when feedback has not been provided by the experts, commenting again makes them receive an email notification, and they may provide you with further information. Experts have no other method of searching for questions in which they have commented, except manually.

2.  Award points by hitting the Accept Comment As Answer button located above and to the left of that expert's comment.

3.  When grading, be sure to read:
https://www.experts-exchange.com/jsp/cmtyQuestAnswer.jsp#3
to ensure that you understand the grading system here at EE. If you grade less than an A, you must explain why.

4.  Questions that were not helpful to you should be PAQ'd (stored in the database for their valuable content?even if not valuable to you) or deleted. To PAQ or delete a question, you must first post your intent in that question to make the experts aware. Then, if no experts object after three full days, you can post a zero-point question at community support to request deletion or PAQ. Please include the link(s) to the question(s).
CS:  https://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
At that point, a moderator can refund your points and PAQ or delete the question for you. The delete button does not work.

5.  If you fail to respond to this cleanup request, I must report you to the Community Support Administrator for further action.

Our intent is to get the questions cleaned up, and not to embarrass or shame anyone. If you have any questions or need further assistance at all, feel free to ask me in this question or post a zero-point question at CS. We are very happy to help you in this task!


thanks!
amp
community support moderator

1/27
Sorry about the delay.
Am clearing up my account and discovered that I had now awarrded you the points for this anser.

Thanks fior the assistance with this problem.

Regards

Richard.