Jump to content











Photo
- - - - -

How to get partitions path in command prompt?


  • Please log in to reply
68 replies to this topic

#1 Peter80

Peter80

    Frequent Member

  • Advanced user
  • 100 posts

Posted 01 January 2015 - 02:40 PM

Anyone know how can i get the partitions path in command prompt in Windows 7? I mean to list the partitions in this way:

\Device\Harddisk0\Partition1
\Device\Harddisk0\Partition2
\Device\Harddisk0\Partition3

with the corresponding drive letters.



#2 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 14758 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 01 January 2015 - 02:53 PM

You need a tool that exposes that particular form of links/names.

Try with dd for windows (using the --list switch):

http://www.chrysocome.net/dd

 

See also:

http://reboot.pro/to...st-and-ddlistw/

 

Or try ListDosDevices:

http://www.uwe-siebe...ivetools_e.html

or check dosdev (it is possible that you have it as part of some SDK/WDK/whatever):

http://blogs.msdn.co.../04/477164.aspx

or get the version by Olof:

http://www.ltr-data.se/opencode.html/

 

 

:duff:

Wonko



#3 Peter80

Peter80

    Frequent Member

  • Advanced user
  • 100 posts

Posted 01 January 2015 - 03:39 PM

Thanks, ListDosDevices does what i want. But are you sure this can't be done only through Windows command prompt? Because few days ago i managed to list the partition this way using only the command prompt but i don't remember what command i used then.



#4 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 14758 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 01 January 2015 - 04:33 PM

Thanks, ListDosDevices does what i want. But are you sure this can't be done only through Windows command prompt? Because few days ago i managed to list the partition this way using only the command prompt but i don't remember what command i used then.

 

Which specific Windows version are you running?

 

Is it possible that dosdev from MS has made it's way from Resource Kit (or whatever into "main" OS)? :unsure:

 

Or maybe you were using WMI/wmic :dubbio:, this would normally do (example) for Physicaldrive enumeration:

wmic diskdrive list brief

 

it is very likely that a similar command can provide that kind of info, I'll have a look for it.

 

 

:duff:

Wonko



#5 Peter80

Peter80

    Frequent Member

  • Advanced user
  • 100 posts

Posted 01 January 2015 - 05:06 PM

I am using Windows 7 Ultimate x32.    



#6 Zharif

Zharif

    Frequent Member

  • .script developer
  • 153 posts
  • Location:Germany
  •  
    Germany

Posted 02 January 2015 - 12:25 AM

What about using wmic?

Here's an example in which I tried to mimic the volume indices.

Please open the file and read comments first.

Then change the file extension from *.txt to *.cmd and run the batch file.

 

 

Attached Files



#7 Zharif

Zharif

    Frequent Member

  • .script developer
  • 153 posts
  • Location:Germany
  •  
    Germany

Posted 02 January 2015 - 12:41 AM

Wait, I just found another batch of mine to demonstrate the abilities of wmic.

I hope at least one of both files is of help.

Attached Files



#8 Peter80

Peter80

    Frequent Member

  • Advanced user
  • 100 posts

Posted 02 January 2015 - 08:52 AM

Thanks, the first script is listing the partitions in the way i need, but it doesn't seem to detect encrypted partitions. I have one partition encrypted with TrueCrypt and it doesn't showing in the list.



#9 Zharif

Zharif

    Frequent Member

  • .script developer
  • 153 posts
  • Location:Germany
  •  
    Germany

Posted 02 January 2015 - 10:43 AM

I found out the fist script is buggy.

It won't display the drive letter "Name" in the right order if one of the volumes doesn't have a drive letter assigned.

My assumption was, that the list containing the volume "Name" is already sorted. But on my Laptop with a hidden recovery partition "wmic volume list > test.txt" this is not the case.

Script needs revision -will work on it.

Maybe jaclaz or Wonko could explain the drive/volume orders more properly.

 

I never used encrypted drives with True Crypt, only files.

Have a look if the DeviceID of your encrypted drive is shown in the full list of "wmic volume".

 

To get a report file of all wmic commands of interest:

- open the command prompt

- type: Type Nul > test.txt

- type: wmic volume list full >> test.txt

- type: wmic logicaldisk list full >> test.txt

- type: wmic partition list full >> test.txt

- type: wmic diskdrive list full >> test.txt

 

Using this report file, you should be able to detect your encrypted partition somewhere.

If so, please report the values you found.



#10 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 14758 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 02 January 2015 - 12:20 PM

Still, it seems like there is not a "plain" WMI/wmic command that could have output by itself the "\Device\Harddisk0\Partition1" kind of listing, from what I could find, the only thing that actually ouptuts that (and not the forms Disk#m, Partition#n or the \\.\PhysicalDriven, etc.) is the Operating System "os", like in WMIC os Get Systemdevice,

 

But it is a non-problem, as I see it, I already provided some methods to hopefully get that info.

As a matter of fact, to be exact, the given tools provide a slightly different "system object" as result. Peter80 possibly did not notice it. :w00t: :ph34r:

 

Those specific kinds of objects should be accessible only by tools like WinObj or DMdiag, see also:

http://reboot.pro/to...-line-possible/

http://reboot.pro/to...emount-ramdisk/

 

So, the actual info asked for can be got from using dmdiag, as follows (example):

dmdiag /v | FIND "\Device\"

What remains is not "how to do" but rather "how Peter80 did or seems to remember he did". :dubbio:

 

@Zharif

The "generic"  issue with WMI/wmic commands is usually that there are a lot of misconfigured WMI installs, so it is not always reliable and some properties/nodes are only available on a given OS release, as an example the alias you use in your script, "volume" as well as it's corresponding class  "Win32_volume" is simply not there on XP.

 

Due to the different nature of the hardware devices (hard disks, super-floppies and similar "volumes", ramdisks, CD/DVD's etc.) and to the complexity with which drive letters are assigned (if any) it is extremely complex to do that kind of mapping in a script, without *something* (like one of the mentioned programs) that wrap around the DosDevices API call, see also:

http://www.msfn.org/...etter-shifting/

http://www.msfn.org/...-drive-letters/

http://www.msfn.org/...ter-batch-file/

 

:duff:

Wonko



#11 Peter80

Peter80

    Frequent Member

  • Advanced user
  • 100 posts

Posted 02 January 2015 - 03:08 PM

Using this report file, you should be able to detect your encrypted partition somewhere.

If so, please report the values you found.

 

This is the output i got from wmic volume list full. The encrypted volume is G:

Automount  BlockSize  Capacity     Compressed  DeviceID                                           DirtyBitSet  DriveLetter  DriveType  FileSystem  FreeSpace   IndexingEnabled  Label       MaximumFileNameLength  Name  QuotasEnabled  QuotasIncomplete  QuotasRebuilding  SerialNumber  SupportsDiskQuotas  SupportsFileBasedCompression  SystemName  
TRUE       4096       16908283904  FALSE       \\?\Volume{a6075fe8-49b3-11e4-9a93-806e6f6e6963}\  FALSE        C:           3          NTFS        1174044672  TRUE                         255                    C:\   FALSE          FALSE             FALSE             11754484      TRUE                TRUE                          PETER-PC     
TRUE       4096       67408752640  FALSE       \\?\Volume{a6075fe9-49b3-11e4-9a93-806e6f6e6963}\  FALSE        D:           3          NTFS        563142656   TRUE             Local Disc  255                    D:\   FALSE          TRUE              FALSE             -1869481847   TRUE                TRUE                          PETER-PC     
TRUE       4096       72135725056  FALSE       \\?\Volume{a6075fea-49b3-11e4-9a93-806e6f6e6963}\  FALSE        E:           3          NTFS        3329355776  TRUE                         255                    E:\   FALSE          TRUE              FALSE             806272371     TRUE                TRUE                          PETER-PC     
TRUE                                           \\?\Volume{be1fc7bf-8dee-11e4-afa3-00a0d1954570}\               G:           3                                                                                      G:\                                                                                                                      PETER-PC     
TRUE                                           \\?\Volume{a6075fed-49b3-11e4-9a93-806e6f6e6963}\               F:           5                                                                                      F:\                                                                                                                      PETER-PC     



#12 Peter80

Peter80

    Frequent Member

  • Advanced user
  • 100 posts

Posted 02 January 2015 - 03:20 PM

What remains is not "how to do" but rather "how Peter80 did or seems to remember he did". :dubbio:

 

 

I clearly remember i copied the path for the encrypted partition from the command prompt because i was trying to create a shortcut from which to mount the partition and for this i needed the partition path. With parameters it looks like this:
 

truecrypt.exe /q /v /lj \Device\Harddisk0\Partition2


I was probably have found the command on google but i can't remember where and i can't remember what the command was.



#13 Zharif

Zharif

    Frequent Member

  • .script developer
  • 153 posts
  • Location:Germany
  •  
    Germany

Posted 02 January 2015 - 03:43 PM

@Wonko,

I see, thank you.

It's a pity I'm not able to download some of the provided files. I don't want create a new account just for this special issue.

What do you think about an initial approach to use mountvol values in combination with fsutil fsinfo volumeinfo?

Jaclaz wrote that mountvol doesn't detect imdisk volumes. But for the rest - is it "reliable" enough to get all local drives?

Maybe combinations with a *vbs created via commandline using fso would provide extensive info, e.g. for network drives.

 

 

@Peter80,

As seen, wmic volume didn't retrieve some useful info to determine drive encryption.

Just for interest, could you post results of the other wmic commands?



#14 Peter80

Peter80

    Frequent Member

  • Advanced user
  • 100 posts

Posted 02 January 2015 - 05:30 PM

As seen, wmic volume didn't retrieve some useful info to determine drive encryption.

Just for interest, could you post results of the other wmic commands?

 

wmic logicaldisk list full

Access  Availability  BlockSize  Caption  Compressed  ConfigManagerErrorCode  ConfigManagerUserConfig  Description       DeviceID  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  
0                                C:       FALSE                                                        Local Fixed Disk  C:        3                                                            NTFS        1174192128                              255                     12         C:                                                                                                               TRUE            FALSE             FALSE             16908283904                      TRUE                TRUE                                      00B35BF4            
0                                D:       FALSE                                                        Local Fixed Disk  D:        3                                                            NTFS        563142656                               255                     12         D:                                                                                                               TRUE            TRUE              FALSE             67408752640                      TRUE                TRUE                          Local Disc  9091F889            
0                                E:       FALSE                                                        Local Fixed Disk  E:        3                                                            NTFS        3329617920                              255                     12         E:                                                                                                               TRUE            TRUE              FALSE             72135725056                      TRUE                TRUE                                      300EBD73            
                                 F:                                                                    CD-ROM Disc       F:        5                                                                                                                                        11         F:                                                                                                                                                                                                                                                                                      
0                                G:                                                                    Local Fixed Disk  G:        3                                                                                                                                        12         G:                                                                                                                                                                                                                                                                                      


wmic partition list full

Access=
Availability=
BlockSize=512
Bootable=TRUE
BootPartition=TRUE
ConfigManagerErrorCode=
ConfigManagerUserConfig=
Description=Installable File System
DeviceID=Disk #0, Partition #0
DiskIndex=0
ErrorCleared=
ErrorDescription=
ErrorMethodology=
HiddenSectors=
Index=0
InstallDate=
LastErrorCode=
Name=Disk #0, Partition #0
NumberOfBlocks=33023999
PNPDeviceID=
PowerManagementCapabilities=
PowerManagementSupported=
PrimaryPartition=TRUE
Purpose=
RewritePartition=
Size=16908287488
StartingOffset=1048576
Status=
StatusInfo=
Type=Installable File System


Access=
Availability=
BlockSize=512
Bootable=FALSE
BootPartition=FALSE
ConfigManagerErrorCode=
ConfigManagerUserConfig=
Description=Installable File System
DeviceID=Disk #0, Partition #1
DiskIndex=0
ErrorCleared=
ErrorDescription=
ErrorMethodology=
HiddenSectors=
Index=1
InstallDate=
LastErrorCode=
Name=Disk #0, Partition #1
NumberOfBlocks=6995968
PNPDeviceID=
PowerManagementCapabilities=
PowerManagementSupported=
PrimaryPartition=TRUE
Purpose=
RewritePartition=
Size=3581935616
StartingOffset=16909336576
Status=
StatusInfo=
Type=Installable File System


Access=
Availability=
BlockSize=512
Bootable=FALSE
BootPartition=FALSE
ConfigManagerErrorCode=
ConfigManagerUserConfig=
Description=Extended w/Extended Int 13
DeviceID=Disk #0, Partition #2
DiskIndex=0
ErrorCleared=
ErrorDescription=
ErrorMethodology=
HiddenSectors=
Index=2
InstallDate=
LastErrorCode=
Name=Disk #0, Partition #2
NumberOfBlocks=272555759
PNPDeviceID=
PowerManagementCapabilities=
PowerManagementSupported=
PrimaryPartition=FALSE
Purpose=
RewritePartition=
Size=139548548608
StartingOffset=20493337088
Status=
StatusInfo=
Type=Extended w/Extended Int 13

wmic diskdrive list full

Availability=
BytesPerSector=512
Capabilities={3,4,10}
CapabilityDescriptions={"Random Access","Supports Writing","SMART Notification"}
CompressionMethod=
ConfigManagerErrorCode=0
ConfigManagerUserConfig=FALSE
DefaultBlockSize=
Description=Disk drive
DeviceID=\\.\PHYSICALDRIVE0
ErrorCleared=
ErrorDescription=
ErrorMethodology=
Index=0
InstallDate=
InterfaceType=IDE
LastErrorCode=
Manufacturer=(Standard disk drives)
MaxBlockSize=
MaxMediaSize=
MediaLoaded=TRUE
MediaType=Fixed hard disk media
MinBlockSize=
Model=Hitachi HTS542516K9SA00 ATA Device
Name=\\.\PHYSICALDRIVE0
NeedsCleaning=
NumberOfMediaSupported=
Partitions=4
PNPDeviceID=IDE\DISKHITACHI_HTS542516K9SA00_________________BBCOC33P\5&243EB0E2&0&0.0.0
PowerManagementCapabilities=
PowerManagementSupported=
SCSIBus=0
SCSILogicalUnit=0
SCSIPort=2
SCSITargetId=0
SectorsPerTrack=63
Signature=855382575
Size=160039272960
Status=OK
StatusInfo=
SystemName=PETER-PC
TotalCylinders=19457
TotalHeads=255
TotalSectors=312576705
TotalTracks=4961535
TracksPerCylinder=255


#15 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 14758 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 02 January 2015 - 06:11 PM

@Zharif
Which files you cannot download?
Just post about them and I will upload them here.
Mountvol uses the volume UUIDs, it is not useful for this, see also:
http://www.msfn.org/...image/?p=895199

But, again what is the problem :w00t:, dmdiag works, as well as dd --list works or can work, *like*:

@ECHO OFF
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
::Links from \HardDiskM\PartitionN to drive letters

SET IsVolume=0
SET IsNTBlock=0
FOR /F "tokens=*" %%A IN ('dd --list 2^>^&1') DO (
SET ThisLine=%%A
SET ThisIncipit=!ThisLine:~0,5!
IF "\\.\V"=="!ThisLine:~0,5!" SET IsVolume=1&SET Thisvolume=%%A
IF !IsVolume!==1 IF "!ThisLine:~0,7!"=="link to" CALL :volume %%A
IF !IsVolume!==1 IF "!ThisLine:~0,7!"=="Mounted" CALL :volume %%A
IF "NT Block"=="!ThisLine:~0,8!" SET IsVolume=0& SET IsNTBlock=1
IF "\\?\Device\H"=="!ThisLine:~0,12!" SET IsVolume=0& SET IsNTBlock=1&SET ThisdeviceH=%%A
IF !IsNTBlock!==1 IF "!ThisLine:~0,7!"=="link to" CALL :deviceH =%%A
)
FOR /F "tokens=2,4 delims==?" %%A IN ('SET \\?\D') DO (
FOR /F "tokens=2,3,5 delims==." %%C IN ('SET \\.\V^|FIND "%%B"') DO (
ECHO  %%E %%A
REM ECHO  %%E %%A %%C
)
)
GOTO :EOF


:volume
SET %Thisvolume%=!%Thisvolume%!=%3
GOTO :EOF

:deviceH
SET %ThisdeviceH%=!%ThisdeviceH%!%3
GOTO :EOF

@Peter80
Maybe you copied them not from the command line, but from the Truecrypt GUI. :unsure: or using some other third party tool. :dubbio:
http://andryou.com/t...-line-usage.php

:duff:
Wonko



#16 Peter80

Peter80

    Frequent Member

  • Advanced user
  • 100 posts

Posted 02 January 2015 - 08:01 PM

Maybe you copied them not from the command line, but from the Truecrypt GUI. :unsure: or using some other third party tool. :dubbio:

http://andryou.com/t...-line-usage.php

 

No, it was from the command prompt window and i didn't use third party tool.



#17 Zharif

Zharif

    Frequent Member

  • .script developer
  • 153 posts
  • Location:Germany
  •  
    Germany

Posted 02 January 2015 - 08:05 PM

@Wonko,

thanks for your offer. Maybe I come back to it.

There's no problem for me to use third party tools like dmdiag or dd. I do use external cmdline tools everyday.

I just tried to cover the initial question of Peter80 to do it somehow with onboard utilities only.

However, such a task seems to be very interesting. I'm curious if it is possible with build-in comdline tool only.

 

The attached script uses mountvol to get the UUIDs, get the corresponding drive letters (if available) and uses fsutil,  in which the UUID were passed. Results are additional string info about the drive type and volume label (if available).

Would you check it please?

The last and most difficult task is to find/get the associated HDD and Partition-Nr.

Attached Files



#18 cdob

cdob

    Gold Member

  • Expert
  • 1438 posts

Posted 02 January 2015 - 08:45 PM

\Device\Harddisk0\Partition1
\Device\Harddisk0\Partition2
\Device\Harddisk0\Partition3

DeviceID=Disk #0, Partition #0
DeviceID=Disk #0, Partition #1
DeviceID=Disk #0, Partition #2


I wonder:
does DeviceID=Disk #D, Partition #P+1 matches \Device\HarddiskD\PartitionP ?

#19 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 14758 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 02 January 2015 - 08:49 PM

@Zharif

Sure, but the original question was not that one, Peter80 remembers to have used a "built-in" tool in a simple way (without writing a batch for it), your nice Zpart thingy works fine here, but I am failing to see it's usefulness, as it simply outputs UUID's with drive letters, and the "added info" from fsutil are not seemingly useful.

Please note how if you try it you will have three possible results for the actual label:

  1. the actual label (good :)
  2. a "NA" (good :)) though usually "N/A" is used when the volume has no label
  3. a "non pronta" (bad :() in English that would be "not ready" but it depends on the parsing besides the localization if the device has a letter assigned but there is no media in it (empty CD/DVD drive or card reader without cards.

:duff:

Wonko



#20 Zharif

Zharif

    Frequent Member

  • .script developer
  • 153 posts
  • Location:Germany
  •  
    Germany

Posted 02 January 2015 - 10:40 PM

Tests with XP, Vista and Win81x64:

I found a way to output "\Device\HarddiskVolume<X>\" value.

It's a fsutil command (fsutil resouce info <DriveLetter or UUID>).

This command is not available under XP.

The attached file checks for the OS. If it is not XP the mentioned string will be displayed additionally.

\Device\HarddiskVolume<X> seems to get the partition number but not the HD number.

 

@Wonko,

Regarding post 3 and 8 I was sure Peter80 prefers not to use a third party tool. But I might be wrong.

 

About the file:

I know that the lbl thing is localised("non pronta"). But till now I see no way to change this.

Please keep in mind that my effords are in an experimental stage.

I worked for it in the last hours just for interest. So, please be patient.

 

In your eyes - what in particular is useful information?

My technical background info about HD structures is very limited.

Your response creates the impression that I'm on a wrong track.

I would be very pleased if you show me the right direction.

Attached Files



#21 Zharif

Zharif

    Frequent Member

  • .script developer
  • 153 posts
  • Location:Germany
  •  
    Germany

Posted 03 January 2015 - 09:10 AM

@Peter80,

 

is your volume displayed now?



#22 Peter80

Peter80

    Frequent Member

  • Advanced user
  • 100 posts

Posted 03 January 2015 - 09:49 AM

@Peter80,

 

is your volume displayed now?

 

This is when it is mounted
 

Drv:   G:\
Lbl:   parameter is incorrect.
Type:  Fixed Drive
UUID:  \\?\Volume{be1fc7bf-8dee-11e4-afa3-00a0d1954570}\
DevID: N/A



This is when it's dismounted
 

 Drv:   G:\
 Lbl:   volume does not contain a recognized file system.
 Type:  Fixed Drive
 UUID:  \\?\Volume{be1fc7bf-8dee-11e4-afa3-00a0d1954570}\
 DevID: N/A

 



#23 Peter80

Peter80

    Frequent Member

  • Advanced user
  • 100 posts

Posted 03 January 2015 - 09:58 AM

I think the right term for these partition paths i am trying to get is ARC paths and i am searching google to find cmd command that can list the ARC paths, but no luck so far. I found a utility from Sysinternals that can list partitions ARC paths, but it doesn't seem very accurate http://technet.micro...s/bb896657.aspx
 It shows that i have 12 partition, but i don't have that much, and it doesn't give much details about the partitions.



#24 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 14758 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 03 January 2015 - 10:05 AM

@Zharif

Don't worry :), I am very patient, you asked me to check it and I reported what I thought might need a refinement/bettering.

Personally I prefer to have things as "narrow in scope" as they can be, if the scope of the batch is to find all volume UUID's and output the corresponding drive letter and further info for each, it is fine as is, if the scope is to find a partition mapping then volumes corresponding to CD/DVD and multicard readers (not ready) should not even be displayed.

 

I am sure that Peter80 has managed to do it *somehow* the issue here is that - unless there is some new, obscure command n Windows 7 that I know nothing about :w00t: :ph34r: - I believe there is no built-in command that will produce that output (and making a batch that assembles a set of commands - if possible - to create that output is surely not what he did at the time) :unsure:.

 

Let's wait if someone comes out with this "unknown" command :dubbio: for that, and let's see in the meantime what we (actually you) can get through the batches. :thumbsup:

 

@Peter80

Not really (an ArcPath is yet another thing) it goes like this:

multi(0)disk(0)rdisk(0)partition(1)

you can get it through recovery console in 2K and XP with map arc:

http://www.microsoft...s.mspx?mfr=true

but it is not used in Vista :ph34r: or later.

 

:duff:

Wonko



#25 Peter80

Peter80

    Frequent Member

  • Advanced user
  • 100 posts

Posted 03 January 2015 - 06:39 PM

I still haven't found the cmd command i had used, but i found a NirSoft program that is listing the partitions the way i want with the corresponding letters for them: http://nirsoft.net/u...etter_view.html






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users