Greetings,
I use a portable 80Gig USB drive where ever I go. When I plug-into someone else's machine, I run an initialization batch to setup the drive letters, enviroment vars, path settings, etc, the way I like. Then, on departure, I have a shutdown batch to put everything back.
A common setting that I have read about, including in this forum, is a batch to allow you to select the Drive Letter of your portable. This is then set to an enviroment variable for use with portable apps.
I didn't like having to always enter the drive letter, so I wrote an automatic method using the DEBUG utility to generate an errorlevel equal to the drive letter. I then substitute drive letter P: for that drive. (I haven't ever had to deal with a system that already used P:, or if it did, I didn't need access to that drive.)
I have attached a sample batch that uses this method. I thought someone else out there might find it useful.
Have fun.
Paul J Crown
---
@echo off
REM USBDRVNM.BAT by Paul J Crown
REM I assume that you are using this on a Win32 system.
REM I have a series of batch files started up when I initialize my portable drive.
REM One of those batch files sets the environment var portable to P, as I typically
REM use P: as my portable drive letter. For this file, you could just insert the
REM letter you use in place of %portable%.
set pdrive=%portable%
set udrive=X
if .%1. == .. goto readdrive
set udrive=%1
goto setdrive
REM I wrote a quick COM file to return the drive letter as
REM an errorlevel. You can create this file using DEBUG.COM.
REM Instructions to create DRVLTR.COM:
REM > DEBUG
REM -a 100
REM mov ah, 19
REM int 21
REM mov ah, 4c
REM int 21
REM [enter]
REM -n DRVLTR.COM
REM -rbx
REM 0000
REM -rcx
REM 0008
REM -w
REM -q
:readdrive
\bin\drvltr.com
if ERRORLEVEL 3 SET udrive=D
if ERRORLEVEL 4 SET udrive=E
if ERRORLEVEL 5 SET udrive=F
if ERRORLEVEL 6 SET udrive=G
if ERRORLEVEL 7 SET udrive=H
if ERRORLEVEL 8 SET udrive=I
if ERRORLEVEL 9 SET udrive=J
if ERRORLEVEL 10 SET udrive=K
if ERRORLEVEL 11 SET udrive=L
if ERRORLEVEL 12 SET udrive=M
if ERRORLEVEL 13 SET udrive=N
if ERRORLEVEL 14 SET udrive=O
if %udrive% == X goto nodrive
goto setdrive
:setdrive
subst %pdrive%: /D >nul
subst %pdrive%: %udrive%:\
goto done
:nodrive
echo Try USBDRVNM D
:done
set pdrive=
set udrive=
----
R McCue
PortaBlog Home and My Website
PortaBlog is now officially out of beta!
"If you're not part of the solution, you're part of the precipitate."