Jump to content

How to give USB drive a FIXED letter?


Recommended Posts


is there any way to give my usb hdd a fixed letter so it is uses same letter in any pc i plugit on ?

Yes and NO.

What do you mean by "any pc", "any pc running any OS" or "any pc running same OS, say XP"?

In any case on first connection of the USB HDD each system will assign a letter automatically, see here also:

http://www.uwe-sieber.de/usbdlm_e.html

What you can do, once windows has assigned it's "automatic" drive letter, is to detect which one is it and change it to "your" default one (provided it is not already occupied).

A batch should be able to do this, by using MOUNTVOL and some small third part utility, like dd for windows, or internal diskpart/WMIC.

A "drive detecting" batch is given here:

http://www.boot-land.net/forums/index.php?...;showtopic=8219

another couple ones by victor888 is here:

http://www.msfn.org/board/index.php?showtopic=123929&hl=

http://www.msfn.org/board/index.php?showtopic=124539&hl=

Just to give you some ideas. ;)

jaclaz

Edited by jaclaz
Link to comment
Share on other sites

i have a usb drive and i have wrote a small batch file to copy files from usb to the hard disk "C:\" but the problem is it is working on my system because the usb is always have the letter F: on my system however it is not working on other systems becase drive letter is being changed

another workorund will work for me if i can use volume name instead of drive letter for copying

thanks

Link to comment
Share on other sites

i have a usb drive and i have wrote a small batch file to copy files from usb to the hard disk "C:\" but the problem is it is working on my system because the usb is always have the letter F: on my system however it is not working on other systems becase drive letter is being changed

another workorund will work for me if i can use volume name instead of drive letter for copying

thanks

This is an entire new question.

If you RUN the batch from the SAME USB drive where the files to be copied are, you DO NOT need to hardcode the USB drive letter anywhere.

Please post/attach your batch.

And/or search about variable expansion of the 0 (zero) parameter of batches (the name of the batch itself).

You can now use the following optional syntax:%~i - expands %i removing any surrounding quotes (")

%~fi - expands %i to a fully qualified path name

%~di - expands %i to a drive letter only

%~pi - expands %i to a path only

%~ni - expands %i to a file name only

%~xi - expands %i to a file extension only

%~si - expanded path contains short names only

%~ai - expands %i to file attributes of file

%~ti - expands %i to date/time of file

%~zi - expands %i to size of file

%~$PATH:i - searches the directories listed in the PATH environment variable and expands %i to the fully qualified name of the first one found.

If the environment variable name is not defined or the file is not found by the search, then this modifier expands to the empty string

The modifiers can be combined to get compound results:%~dpi - expands %i to a drive letter and path only

%~nxi - expands %i to a file name and extension only

%~fsi - expands %i to a full path name with short names only

%~dp$PATH:i - searches the directories listed in the PATH environment variable for %i and expands to the drive letter and path of the first one found.

%~ftzai - expands %i to a DIR like output line

In the above examples %i and PATH can be replaced by other valid values.

I.e. make a batch with :

ECHO %~d0
ECHO %~dp0
ECHO %~dpn0
ECHO %~dpnx0

and run it from the USB stick.

jaclaz

Link to comment
Share on other sites

If you are just copying the same files from your usb to the local disk, how about some relative path action.

like copying everything in the batch files current directory

xcopy .\*.* c:\

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...