Use Volume Label instead of Drive Letter for USB Thumb Drive

By srobieson ·
Is it possible in a DOS batch file to set the drive to look for volume label instead of drive letter that changes?

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Answers

Collapse -


by robo_dev In reply to Use Volume Label instead ...

What are you trying to do, exactly?

I'm guessing that your question has something to do with volume mount points used in Windows 2000 and later...there's a program that's part of windows called mountvol that could be used in a dos batch file.

therefore, the way to see the volume name for a d: drive would be

mountvol d: /L

Collapse -

Backup files to USB

by srobieson In reply to clarify

I am trying to create a batch file to backup user info on thumb drive prior to re-image. The USB device gets assigned a different drive letter depending on number of installed or mapped drives. Drive is labeled USB.
%backupcmd% "%USERPROFILE%\Favorites" d

Collapse -

Try this

by Jacky Howe In reply to Use Volume Label instead ...

Open explorer and create a new folder. Something like USB. Insert the Memory stick. Open Computer Management, Disk Management and right click on the removable disk. Select Change Drive Letter and Paths. Here you can select a Drive Letter of choice by clicking Change, Select Add. Navigate to the folder and Select it and press OK. From now on when you insert the Memory stick you will have a copy of the contents in the new folder. You can set the batch file to the new drive letter without it ever changing.

Collapse -

If you are running the batch file from the USB try this

by Jacky Howe In reply to Use Volume Label instead ...

@echo off
:: variables
set path=%~dp0Backup;%path%
set drive=%~dp0Backup
set backupcmd=xcopy /s /c /d /e /h /i /r /k /y

if not exist "%drive%\Backup" mkdir "%drive%\Backup"
:: echo ### Backing up My Documents...
if not exist "%drive%\My Documents" mkdir "%drive%\My Documents"
%backupcmd% "%USERPROFILE%\My Documents" "%drive%\My Documents"

echo ### Backing up email and address book (Outlook Express)...
if not exist "%drive%\Address Book" mkdir "%drive%\Address Book"
%backupcmd% "%USERPROFILE%\Application Data\Microsoft\Address Book" "%drive%\Address Book"
if not exist "%drive%\Outlook Express" mkdir "%drive%\Outlook Express"
%backupcmd% "%USERPROFILE%\Local Settings\Application Data\Identities" "%drive%\Outlook Express"

echo ### Backing up email and contacts (MS Outlook)...
if not exist "%drive%\Outlook" mkdir "%drive%\Outlook"
%backupcmd% "%USERPROFILE%\Local Settings\Application Data\Microsoft\Outlook" "%drive%\Outlook"

:: echo ### Backing up the Registry...
:: if not exist "%drive%\Registry" mkdir "%drive%\Registry"
:: if exist "%drive%\Registry\regbackup.reg" del "%drive%\Registry\regbackup.reg"
:: regedit /e "%drive%\Registry\regbackup.reg"

:: use below syntax to backup other directories...
:: %backupcmd% "...source directory..." "%drive%\...destination dir..."

echo Backup Complete!

Related Discussions

Related Forums