How to add the equivalent of Novell's Map command to Windows

Discussion in 'Application Software' started by Palladin, May 29, 2015.

  1. Palladin

    Palladin MDL Senior Member

    Feb 1, 2014
    332
    139
    10
    #1 Palladin, May 29, 2015
    Last edited: May 30, 2015
    There was very useful program built into Novell Netware called Map that would tell you the what drives were mapped to which drive letters. AFAIK there isn't a one built into any current version of Windows. I figured I could cobble something together so the hunt began. It didn't take that long to locate a couple native Windows programs to get the job done. Nothing as elegant as the original Novell Map command, but they gave me the information I wanted.

    The first one is DiskPart. It's kinda clunky and there are a couple of ways to use it. The first one is to start an elevated CMD session and type Diskpart. You will then get a C:\DISKPART> prompt. Then type "list volume" (two words, without the quotes) and you should see something like this:
    DiskPart-1.jpg
    There doesn't seem to be any way to run any options from the CMD session, you have to load Diskpart. But you *can* run a Diskpart script from CMD. Seems goofy, but that's all I could figure out. You need to make a couple of small files to get this done. One is a simple batch file, and the other is a small text file. The batch file looks like this, but you could modify it to suit your needs:
    @echo off
    cls
    c:
    cd \
    diskpart /s c:\ut\map.txt
    pause
    Then create a text file with Notepad and put just two words in it... List Volume and save it as map.txt
    Be sure to put both the batch file, and Map.txt somewhere in your path. And be sure that the name of the script file that is called in the batch file matches the name of the text file with List Volume in it.

    It's pretty much a Kluge, but it works. Then type Map at any CMD prompt and you will get the same output as if you started up Diskpart, and ran List Volume within Diskpart. There should be a way to get all of this into one batch file, but I couldn't figure out a way to pass "List Volume" to Diskpart within the batch file. And I couldn't find any way to format the output so some of the information is truncated in the table. o_O

    The other way is a bit more elegant, if not more complicated. The Windows program is called WMIC or Windows Management Instrumentation Command. Unlike Diskpart there are countless options in this program. I found the documentation very cryptic and after fumbling around for a while I found the commands to do what I wanted.

    The that seems to do the best job is wmic logicaldisk get
    You can add several arguments to this basic command to display different information.
    The full syntax of the command is:
    Property get operations.
    USAGE:
    GET [<property list>] [<get switches>]
    NOTE: <property list> ::= <property name> | <property name>, <property list>
    The following properties are available:
    Property
    ========
    Access
    Availability
    BlockSize
    Caption (same as DeviceID)
    Compressed
    ConfigManagerErrorCode
    ConfigManagerUserConfig
    Description
    DeviceID (same as Caption)
    DriveType
    ErrorCleared
    ErrorDescription
    ErrorMethodology
    FileSystem
    FreeSpace
    InstallDate
    LastErrorCode
    MaximumComponentLength
    MediaType
    Name
    NumberOfBlocks
    PNPDeviceID
    PowerManagementCapabilities
    PowerManagementSupported
    ProviderName
    Purpose
    QuotasDisabled
    QuotasIncomplete
    QuotasRebuilding
    Size
    Status
    StatusInfo
    SupportsDiskQuotas
    SupportsFileBasedCompression
    VolumeName
    VolumeSerialNumber

    The following GET switches are available:

    /VALUE - Return value.
    /ALL(default) - Return the data and metadata for the attribute.
    /TRANSLATE:<table name> - Translate output via values from <table name>.
    /EVERY:<interval> [/REPEAT:<repeat count>] - Returns value every (X interval) seconds,
    If /REPEAT specified the command is executed <repeat count> times.
    /FORMAT:<format specifier> - Keyword/XSL filename to process the XML results.

    NOTE: Order of /TRANSLATE and /FORMAT switches influences the appearance of output.
    Case1: If /TRANSLATE precedes /FORMAT, then translation of results will be followed by formatting.
    Case2: If /TRANSLATE succeeds /FORMAT, then translation of the formatted results will be done.
    Not exactly a walk in the park to decipher, but here's what I came up with. There are two basic formats. One tabular and one listing each tabular listing as a group.

    This gives a table listing (/all is the default)

    wmic logicaldisk get volumename, description, freeSpace, size, caption, volumeserialnumber

    DiskPart-2.jpg
    Note: the order of the commands doesn't matter, the output is arranged alphabetically no matter what. And I don't think there is a way to format the numbers any differently than they are displayed. It would be nice if you could insert commas so 828408590336 becomes 828,408,590,336.

    The grouping listing is done by adding /Value to the end of any of the commands.
    wmic logicaldisk get volumename, description, freeSpace, size, caption, volumeserialnumber
    /Value
    And the outpul looks like this:
    DiskPart-3.jpg

    Now Windows has a Map command. :biggrin: