Partilhar via


Evolution of a solution

The other day, someone posted a message at work asking for a way to find out the drive letter for partition 1 on the first disk.

The first response offered this:

C:>echo list volume | diskpart

Microsoft DiskPart version 5.1.3565

Copyright (C) 1999-2003 Microsoft Corporation.

On computer: SINISTAR

DISKPART>

Volume ### Ltr Label Fs Type Size Status Info

---------- --- ----------- ----- ---------- ------- --------- --------

Volume 0 F DVD-ROM 0 B

Volume 1 C BOOTDRIVE FAT32 Partition 9 GB Healthy System

Volume 2 D Application NTFS Partition 15 GB Healthy Pagefile

Volume 3 E SharedAndUn NTFS Partition 10 GB Healthy

DISKPART>

C:\>

The original poster then asked if anyone already had a script to parse the output of diskpart. I helpfully offered this:

@for /f "tokens=3" %%x in ('echo list volume ^| diskpart ^| findstr /c:"Volume %1"') do @echo %%x

"How clever of me," thought I. "Simply pass in a volume number and it neatly spits out the drive letter." I was all proud of myself until someone pointed out that we already had a perfectly good .exe that did the same thing.

The moral? It's all fun and games 'til you find out you just reinvented the wheel...

Comments

  • Anonymous
    October 01, 2005
    ..and what is the name of that exe? thanks.
  • Anonymous
    October 03, 2005
    The comment has been removed