home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Media Share 9
/
MEDIASHARE_09.ISO
/
utility
/
pbaseiv.zip
/
P4UTL002.TIP
< prev
next >
Wrap
Text File
|
1991-12-16
|
2KB
|
73 lines
Many batch files change the current directory on one or more
of your system's drives. Unfortunately, there's no way for a
batch file to know what directory you're in when you run it,
and therefore no way for it to return to its directory of
origin.
That is, until now. I've written a short assembly language
program, BACK.COM, that lets batch files do just that. The
program saves the current directory's path in a
directory-changing batch file. By putting this command at
the beginning of a batch file and--via the CALL
command--running the batch file it creates at the end,
you'll ensure that your batch file will always start and end
in the same directory, regardless of where it goes in
between.
Charles N. Jackson III
Silver Spring, Maryland
Editor's note: I rewrote BACK.COM to make it smaller and
more bulletproof, then added it to some of my batch files,
where it worked wonderfully. At that point, I realized I
wanted a second, similar utility; one that would return me
to the drive I was logged on to before the batch file ran. I
created another program, BACKD.COM, which generates a batch
file to accomplish this. As with BACK.COM, you put BACKD.COM
at the beginning of your batch file and the file it creates
at the end.
BACK.COM and BACKD.COM are both included, in executable
form, in the P4UTIL directory on your PowerBase *.* Volume
IV diskette.
The following listing shows how to use both BACK.COM and
BACKD.COM. (You can copy the listing to a file by pressing
the Alt-F key.) Note that you can use BACK.COM several times
to restore the original directory on any number of drives.
On the other hand, you need to use BACKD.COM only once--to
restore the original drive before the batch ends.
Using BACK.COM and BACKD.COM
---- BEGIN LISTING ----
@ECHO OFF
REM Save the current drive
BACKD > D:\DRIVE.BAT
REM Save current directories of drives
REM C: and D:
C:
BACK > D:\CBACK.BAT
D:
BACK > D:\DBACK.BAT
REM Run WordPerfect from drive D:
REM and pass it the command line parameters
CD \WP51 /w=* /d=d:\ %1 %2 %3 %4
REM Restore everything
CALL D:\CBACK.BAT
CALL D:\DBACK.BAT
CALL D:\DRIVE.BAT
REM Clean up
DEL D:\CBACK.BAT > NUL
DEL D:\DBACK.BAT > NUL
DEL D:\DRIVE.BAT > NUL
ECHO ON
---- END LISTING ----
Title: Finding Your Way Back Home
Category: DOS
Issue Date: Dec 1991
Editor: Brett Glass
Supplementary files: P4UTIL\BACK.COM, P4UTIL\BACKD.COM