I use a batch file to copy several folders containing data files to a flash drive once a week. The problem is I have to edit the file almost every time I use it because the flash drive letter may have changed from the last time I ran the program. I would like to have the program ask for the correct drive letter and then carry on copying folders to this drive. Thanks for your help.
![]() |
Patch reliability is unclear, but widespread attacks make patching prudent. Go ahead and patch, but watch out for potential problems. |
-
Need help with batch file [RESOLVED]
Home » Forums » AskWoody support » Backup » Backup – other » Need help with batch file [RESOLVED]
- This topic has 9 replies, 7 voices, and was last updated 1 month, 1 week ago by
anonymous.
Viewing 8 reply threadsAuthorReplies-
zat_so
AskWoody PlusMay 22, 2022 at 11:17 am #2448280If you go into Computer Management, you can assign a drive letter to that drive. I suggest choosing a letter near the bottom of the alphabet, since it would be unlikely to ever be used otherwise. My flash drive, for instance, is Drive Q every time I plug it in (daily). If for whatever reason that doesn’t work for you, post back and we’ll try Plan B.
-
RobertG
AskWoody Plus -
anonymous
GuestMay 22, 2022 at 6:18 pm #2448343See also another approach to react on changing drive letters: https://stackoverflow.com/questions/10147302/batch-file-and-variable-usb-drive-letters/56246725#56246725
-
RetiredGeek
AskWoody MVPMay 22, 2022 at 8:40 pm #2448383I use a free program called USBDLM (USB Drive Letter Management). It allows you to assign drive letters automatically based on the Volume Serial number of a device. THe VolSer No only changes if you either Reformat the drive or use a program to change it.
I use it to control my 6 different bare hard drives that I use for taking system images with Macrium Reflect. I have it set so any one of the 6 will automatically mount as I: (for Image) whether I mount on any one of my machines with a USB drive dock. Works like a charm.
HTH
-
TechTango
AskWoody Plus -
Paul T
AskWoody MVP -
BATcher
AskWoody_MVPMay 23, 2022 at 1:43 am #2448431If you can run the BATch file from the USB flash drive itself, then you can determine dynamically the drive letter plus colon (e.g. F:) from a variable, as follows:
Code::: determine the drive letter (plus colon) of the :: USB drive whereon this BATch file is located set usb=%~d0 echo %usb% pause
BATcher
Plethora means a lot to me. -
steeviebops
AskWoody PlusMay 25, 2022 at 4:34 am #2448906If you want your batch file to prompt for the drive letter like you asked, you can do it this way.
set /p dl=”Enter drive letter: ”
You’d then replace the drive letter in your commands with the variable name %dl% – e.g.
robocopy c:\source %dl%:\target /e
The solutions above might be better though.
-
anonymous
Guest
Viewing 8 reply threads - This topic has 9 replies, 7 voices, and was last updated 1 month, 1 week ago by
-
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments. Click here for details and to sign up.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Arch Linux Current Release: 2022.07.01
by
Alex5723
51 minutes ago -
OlderGeeks.com is not secure
by
Alex5723
12 minutes ago -
Word 2013 will not start after Windows Update
by
arfurdent
3 hours, 22 minutes ago -
Cyber criminal techs doing deepfakes to get remote jobs
by
HemetCPA
15 hours, 56 minutes ago -
Phishing email subjects that get the most clicks….
by
CAS
14 hours, 5 minutes ago -
USB installer tool removes Windows 11’s Microsoft account requirements
by
bbearren
1 day, 5 hours ago -
June windows Update, Shell Infrastructure Host, Higher RAM
by
bashbish
1 day, 18 hours ago -
Windows 11 22H2 Insider Preview build 22621.169 released to Release Preview
by
joep517
1 day, 21 hours ago -
How to stop AT&T from selling your private data to advertisers
by
Alex5723
2 days ago -
TweetDeck for Mac is shutting down on July, 1
by
Alex5723
2 days, 10 hours ago -
Windows 11 23H2 Insider Preview build 25151 released to DEV
by
Alex5723
23 hours, 6 minutes ago -
PDF24 Creator updates
by
Alex5723
2 days, 23 hours ago -
FCC commissioner calls on Apple and Google to remove TikTok app.
by
Alex5723
1 hour, 49 minutes ago -
My Windows 10 Pro 21H2 (OS Build 19044.1766) was offered Windows 11
by
bbearren
2 days, 16 hours ago -
posting is a general problem
by
astro46
2 hours, 2 minutes ago -
When i am trying to send mail i am seeing /o=Exchange/ou=Exchange Administrative
by
abulker
3 days, 4 hours ago -
Micropatching the “PrinterBug/SpoolSample”
by
Nibbled To Death By Ducks
3 days, 11 hours ago -
Sites rejecting my email
by
Marlene Partridge
3 days, 10 hours ago -
Print single page inside multi page document without going to print menu
by
Ronaldmarr
1 day, 22 hours ago -
PSI program
by
Milton W
3 days, 9 hours ago -
Trouble with USB headphones not being recognized, or something
by
Cthru
18 hours, 24 minutes ago -
Clear Disk Info Warning Status on SSD
by
CraigS26
3 days, 4 hours ago -
OneDrive update manifesting itself differently in three separate accounts
by
TonyC
1 day, 10 hours ago -
Can a heading style include text?
by
louiscmac
4 days, 5 hours ago -
Windows Defender can Significantly Impact Intel CPU Performance
by
Alex5723
3 days, 19 hours ago -
Convert VB code to run on both PC & Mac
by
Bill Roberts
4 days, 10 hours ago -
MS-DEFCON 3: Should we patch?
by
Susan Bradley
14 minutes ago -
T-Mobile is now selling Android app usage data to advertisers
by
Alex5723
20 hours, 55 minutes ago -
Controlled Folder Access more trouble than it is worth.
by
astro46
3 days, 2 hours ago -
New SSD – A “Ghost” Drive Letter But Otherwise Not Visible to Win 10
by
Shiseiji
4 days ago
Recent blog posts
- MS-DEFCON 3: Should we patch?
- The right to repair
- The hard drive is dead; long live solid-state storage
- Getting to one OneNote on Windows
- FocusWriter — Don’t get distracted by squirrels and things
- Dealing with DCOM
- Windows 8.1 is getting close to the finish line
- So they tortured Windows 10 users first?
Key Links
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2022 by AskWoody Tech LLC. All Rights Reserved.