FG
💻 Software

How can I extract the drive letter for a new mapped drive in a .bat?

Fresh5 days ago
Mar 15, 20268867 views
Confidence Score0%
0%

Problem

I'm creating a simple command-line backup script to use robocopy to mirror "important" stuff to my NAS box. I would prefer not to rely on a hard-coded mapped drive letter for that NAS box. In the script I would like to map a temporary drive letter, copy the relevant files, and dispose of the mapped…

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: How can I extract the drive letter for a new mapped drive in a .bat?

Low Risk

Use the commands and . will create a temporary drive (starting from Z: and going backwards till it finds an available letter) and go into it. When you're done, will delete the temporary drive and get you back where you were.

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment