Reference a Volume/Drive by Label

前端 未结 3 1445
天涯浪人
天涯浪人 2020-12-18 04:54

I\'m trying to write a batch file to xcopy a folder to a removable USB drive. The problem that I face, however, is that drive letters are subject to change, so I would like

3条回答
  •  不知归路
    2020-12-18 05:07

    For my needs, I use the following in a batch file that looks for the Drive labeled "System" (This is where my Windows 7 OS is installed) and it puts the Drive Letter associated with the label "System" into a variable named %SystemVolume_DriveLetter%

    for /f "delims=" %%l in ('WMIC Path Win32_volume where "Label='System'" Get DriveLetter /format:list') do >nul 2>&1 set "SystemVolume_%%l"
    

提交回复
热议问题