batch file question

CityK

Storage Freak Apprentice
Joined
Sep 2, 2002
Messages
1,719
1 ) This first question deals with the concept of portability. Namely, I would like to be able to run a batch file contained on a regular (i.e. non bootable) CD-Rom, and running under a Win32 environment, on different systems. The batch file will be calling two programs that are also contained on the rom disc, but need to be placed in seperate directories.

How do I set the path of those programs in the batch file in such a manner as to eliminate the problem associated with using the CD-Rom in different systems (i.e. they will likely have different names/assignments for their rom drives, so using a static drive path name won't work)

I saw something in Barts boot disk stuff, but I don't know if it would apply.
 

CityK

Storage Freak Apprentice
Joined
Sep 2, 2002
Messages
1,719
Oops. Was going to post a couple of questions, but am too tired. One it is for now.
 

sechs

Storage? I am Storage!
Joined
Feb 1, 2003
Messages
4,709
Location
Left Coast
It's been a while, but shouldn't you be able to use the path relative to the batch file's location to do this?
 

Buck

Storage? I am Storage!
Joined
Feb 22, 2002
Messages
4,514
Location
Blurry.
Website
www.hlmcompany.com
When a batch file is executed, it assumes all locations are local to its directory, unless otherwise specified. Thus, you could simply write something like:
Code:
@echo off
cd directory1
program1.exe
cd ..
cd directory2
program2.exe
 

CityK

Storage Freak Apprentice
Joined
Sep 2, 2002
Messages
1,719
I'm sorry, I completely bungled my question last night by omitting the two key elements to my problem. Here's the way I want to organize the disk:

Code:
..
|
| - <directory 1>
|       program1.exe
|
| - <directory 2>
|       program2.exe
|
|- <directory 3>
        batch file
        textfileA
        textfileB

Now the complication is that the command line used for the programs has to call/refer to the the text files. For example:

program1.exe <path>\textfileA

And in this case, path is going to be

<drive>\directory3\

So, the real question 64 thousand dollar question revolves around the <drive> portion of the path used on the program cmdline. How do I assign a dynamic drive name?
 

Howell

Storage? I am Storage!
Joined
Feb 24, 2003
Messages
4,740
Location
Chattanooga, TN
CityK said:
I'm sorry, I completely bungled my question last night by omitting the two key elements to my problem. Here's the way I want to organize the disk:

Code:
..
|
| - <directory 1>
|       program1.exe
|
| - <directory 2>
|       program2.exe
|
|- <directory 3>
        batch file
        textfileA
        textfileB

Now the complication is that the command line used for the programs has to call/refer to the the text files. For example:

program1.exe <path>\textfileA

And in this case, path is going to be

<drive>\directory3\

So, the real question 64 thousand dollar question revolves around the <drive> portion of the path used on the program cmdline. How do I assign a dynamic drive name?

I'm with sechs, does this not work:

program1.exe ..\directory3\textfileA
 

CityK

Storage Freak Apprentice
Joined
Sep 2, 2002
Messages
1,719
Oops, I'm an idiot. I left something out again. The cmdline should be something like
program.exe Argument="<path>\filename"
I tried using:

program.exe Argument="..\directory3\textfileA"

but I think the Argument= chokes on the ".."

Any ideas? Thanks for the help so far.
 

Fushigi

Storage Is My Life
Joined
Jan 23, 2002
Messages
2,890
Location
Illinois, USA
Can you place program.exe in a batch file? Something like this:

Code:
@echo off
cd ..\textfiledirectory
..\programdirectory\program.exe Argument="textfileA"
 

Tea

Storage? I am Storage!
Joined
Jan 15, 2002
Messages
3,749
Location
27a No Fixed Address, Oz.
Website
www.redhill.net.au
Write a series of short, easy batch files. Call them:

DDRIVE.BAT
EDRIVE.BAT
FDRIVE.BAT
GDRIVE.BAT

and so on.

When you start up the system, go to the CD-ROM drive (let's say it's F: in this particular case) and type FDRIVE.

Then run your main batch program. (Or you could have the FDRIVE batch file chain to it if you prefer.) The small batch files simply need to set an environmental variable for the required drive letter. I have samples at the office which I could post, if you like. It's very easy to do.
 

Tea

Storage? I am Storage!
Joined
Jan 15, 2002
Messages
3,749
Location
27a No Fixed Address, Oz.
Website
www.redhill.net.au
This is an old one Tannin used to use for batch-driven setup of DOS machines. You'll get the idea.

FDRIVE.BAT
set drv=f
call %drv%:\setdrive

(All the other ones, DDRIVE.BAT and EDRIVE.BAT and so on, are semi-identical)

SETDRIVE.BAT
set drive=%drv%:
path %drv%:\;%drv%:\xtg;%drv%:\standard;\dos;%path%;
if '%prompt%'=='' prompt $p$g
%drive%\standard\xms
%drive%\standard\smartdrv
copy %drv%:\xtg\xtg-%drv%.cfg %drv%:\xtg\xtgold.cfg
copy %drv%:\xtg\xtg-%drv%.com %drv%:\xtg\xtgold.com

STANDARD.BAT
set source=%drive%\standard
call %source%\inst-win
set source=%drive%\standard
call %source%\install
cd\
%drive%
if %1!==! goto end
if %1==63 set DOSZIP=IBM63.zip
if %1==70 set DOSZIP=IBM70.zip
if %1==50 set DOSZIP=MS50.zip
if %1==620 set DOSZIP=MS620.zip
if %1==622 set DOSZIP=MS622.zip
md c:\dos
pkunzip -d %drive%\dos\%DOSZIP% c:\dos
:END

So, to setup DOS 6.3 with a whole stack of sharware programs (100 or so), a customized menu system, and Windows 3.x pre-copied to an installation folder, all you had to do was type:

FDRIVE
STANDARD 63

For DOS 6.22 from the G: drive, you typed:

GDRIVE
STANDARD 622

Does this make any sense?
 

CityK

Storage Freak Apprentice
Joined
Sep 2, 2002
Messages
1,719
Well I didn't go the multiple batch route, but Fushigi handed me the last piece to complete my goal.

Code:
@echo off
"..\directory 1\program1.exe" Arguement="TextfileA" 
@echo wait until program1 reports its done, then
@echo off
pause
"..\directory 2\program2.exe" Arguement="TextfileB"
 

CityK

Storage Freak Apprentice
Joined
Sep 2, 2002
Messages
1,719
Tea said:
This is an old one Tannin used to use for batch-driven setup of DOS machines. You'll get the idea.....
Does this make any sense?
Err, if by sense you mean does it make my head spin, then yes. Yes it makes perfect sense :D
 

CityK

Storage Freak Apprentice
Joined
Sep 2, 2002
Messages
1,719
BTW, thanks for all the help with this one guys. Its working beautfully.
 
Top