-2

I was trying automate modifing some files on another drive (boot files for raspberry pi). I want to add couple lines of text to config.txt and cmdline.txt but windows alwas mounts the boot drive with diffrent drive letter (label stays the same: "boot"). I need to change directory (in batch file) to rpi's boot drive (label: "boot"). Can you help?

pacjo
  • 1
  • See https://stackoverflow.com/questions/61738542/how-to-access-a-usb-drive-using-its-label-and-navigate-with-cmd/61739493#61739493 I feel like the answers there are well-suited for your question – Nico Nekoru Jun 22 '20 at 19:17

2 Answers2

1

On a regular Windows computer, you can use wmic for getting Windows configuration information, like this here:

wmic logicaldisk get description,caption

You might also use:

wmic logicaldisk list

In case this does not help, you might try the following:

wmic volume get label, name
Dominique
  • 16,450
  • 15
  • 56
  • 112
  • 1
    I used this: "wmic logicaldisk get volumename,name", I need labels of disks not drive letters, also how can I use this info in batch file to change to disk with label "boot"? – pacjo Jun 22 '20 at 10:12
  • 1
    Using a command output as a variable is a burden indeed in batchfiles, I can give you this reference to start with: https://stackoverflow.com/questions/6359820/how-to-set-commands-output-as-a-variable-in-a-batch-file – Dominique Jun 22 '20 at 10:32
  • 1
    As for the label, instead of "logicaldisk", you might try "volume", like `wmic volume get label, name`, is this what you're looking for? – Dominique Jun 22 '20 at 10:34
  • @pacjo: I've adapted my answer accordingly. Please upvote or accept my answer. – Dominique Jun 22 '20 at 11:29
1

In order to determine the drive letter associated with the label boot, and change the current directory to the root of it, I would expect that a command such as this would perform the expected task:

@For /F "Tokens=2 Delims==:" %%G In ('%__APPDIR__%wbem\WMIC.exe Volume Where "Label='boot'" Get DriveLetter /Value 2^>NUL') Do @CD /D %%G:\

Please note that, there is no functionality built into this single line code, to cater for the possibility that you may have more than one attached volume, with the same label.

Compo
  • 36,585
  • 5
  • 27
  • 39