1.

Solve : Determining the base path from random computers in removable media?

Answer»

Now here is a challenge for the masses, though any help is appreciated.
I have two hot-swappable devices (a USB DRIVE and an iPod, respectively) that I USE occasionally with computer repair, among other reasons. This, in and of itself, is not the problem.
What I am after, specifically, is being able to run a shortcut from the USB drive, through a batch file, and so run a program on the iPod, without knowing what the respective drive letters are for either devices.
I am aware of the relative path function, which I frequently use between the USB device and the computer itself. The question is whether or not it is possible to use two non-root relative paths, and have it work.
The typical operating system would be XP Pro, as I recall.
(And no, in case you might be curious, it is not HOMEWORK. )

Any help in this would be most appreciated.Yes, this can be done.

To get the drive letter of the device the current batch file is running on you can use:
%~d0

For example:
Code: [Select]@echo off
echo This batch file is running from drive %~d0
From reading your question, it is not clear if you also want a batch file from the USB flash drive to get the drive letter of the iPod, or a batch file from the iPod to get the drive letter of the USB flash drive. This can also be done by using the command:
fsutil fsinfo volumeinfo
You will just have to record the volume serial number for each, and then loop through the available drive letters searching for the serial number(s) by hard-coding the values you are looking for.

Does that help?You have the right idea, I suspect. I prefer the file to be able to do it either way, but for now, start with the USB tring to get the drive letter of the iPod. Unfortunately, I do not know at this point how to scan the drives for the serial.
Overall, this is the goal:
* Determine what the drive letter is.
* Save the drive letter as a variable.
* Copy several dll files from the iPod to the system disk.
* Be able to execute an EXE program in the iPod.

And then, when finished, delete said files from the system disk.
Copying and deleting to the system isn't too hard. It's simply determinig/using the letter in a copy path. (And, as stated, knowing how to determine/use the serial.

I hope this helps.Choose drive letters for each device and assign them in Disk Management. Select 2 letters that won't commonly appear on most machines such as U: and V:

Once you have done this return to Disk Management one device at a time and also assign them a Volume label... such as USBDrive and IPod one.....up to 11 characters i believe.

This helps the drive letters " stick" across Windows platforms for some unknown Bill Gates reason...but it simply works.

When you are done the only way this will not work is if you plug them into a machine that's using those drive letters ( highly unlikely )

This will greatly simplify your batch file creation and variables.

While the attempts at help are appreciated, it doesn't appear to be true. I have tested it for the USB with a different name, different letter, different name and letter, and multiple letter types. The drive letter changed every time.
It looks like I'll have to do it the long way around.
Gentlemen, start your coding.

(Kidding. )Provided the drives have unique labels, you can use the diskpart utility to iterate thru the assigned drives.

Code: [Select]@echo off
for /f "tokens=3,4" %%i in ('echo list volume ^| diskpart ^| FIND /i "removeable"') do (
if /i "%%j"=="ipod" set ipod=%%i:
if /i "%%j"=="flash" set flash=%%i:
)


You can use the variables %ipod% and %flash% as needed.

Good luck.

You may have to change the if statements to match the actual labels on your devices.Quote from: Torano on May 15, 2007, 03:11:16 PM

While the attempts at help are appreciated, it doesn't appear to be true. I have tested it for the USB with a different name, different letter, different name and letter, and multiple letter types. The drive letter changed every time.
It looks like I'll have to do it the long way around.
Gentlemen, start your coding.

(Kidding. )

I disagree.
I have 4 different flash drives...different brands and no matter where i plug them in, no matter what customer's machine, they retain the drive designation i gave them.Quote from: patio
I disagree.
I have 4 different flash drives...different brands and no matter where i plug them in, no matter what customer's machine, they retain the drive designation i gave them.

I am not saying that it doesn't work for you, Patio. I'm saying that it doesn't work on the computers and flash drives I am using.
What I am wondering, though, is what kind of partition you have on them. The only formatting I didn't have at the time was NTFS, which might be a possible reason, however unlikely.
Another thought that has occurred to me after the fact is that I was referring to the drive letters themselves. So if you were referring to the drive name in specific, then yes, it is retained. Otherwise, no.

Sidewinder: It isn't exactly what I was after, to be honest, but it does appear to be working for my purposes. Thank you.Drive letters and Volume labels are retained no matter what file system i use.

There is no reason to format flash memory anything but FAT32 but one i keep FAT16 for older systems.

Perhaps this hasn't worked in your case because you re-named the drives instead of preparing them as i said.

I do the above steps after a full format and it's never failed me. Maybe this is not the case if you just rename / designate a drive letter on a previously designated drive...Quote from: patio
I do the above steps after a full format and it's never failed me. Maybe this is not the case if you just rename / designate a drive letter on a previously designated drive...

Simply put, yes.
I was in the process of fieldwork when I was experimenting, and had no place (or at least, not enough time) to unload, format, and re-copy the drive materials. (That, and I still use the nearly-full 30 GB iPod for its actual purpose, as well as storage space.)
In any event, the effort is appreciated, and I will keep it in mind for the future.Any problems so far mixing data files and tunes on the 30G iPod ? ?

Been thinkin about grabbing one...(Sorry about taking so long to reply...)

If you haven't gotten one already, there hasn't been a problem yet. It appears that the programming is closed-table software, and doesn't recognize anything it doesn't specifically create, save notating an "other" on the drive space.


Discussion

No Comment Found