find out which partiton

  • Thread starter Thread starter Randall Flagg
  • Start date Start date
R

Randall Flagg

Hi there

i have to find out which partitions do exist on harddisk 0 on a large number
on computers.

found a way to do it with a script using diskpart unfortunately this does
not work on Windows NT.

i need the existing drive letters for this partitions on Windows NT 4.0 SP6
and Windows 2000 / XP...

does anyone know a way to get this info by WSH-Script, shell script or a
little command line tool?

Thanks in advance
 
In said:
Hi there

i have to find out which partitions do exist on harddisk 0 on a
large number on computers.

found a way to do it with a script using diskpart unfortunately
this does not work on Windows NT.

i need the existing drive letters for this partitions on Windows
NT 4.0 SP6 and Windows 2000 / XP...

does anyone know a way to get this info by WSH-Script, shell
script or a little command line tool?

Letter-designated "volumes" may be listed with psinfo.exe. Note that
unformatted, un-lettered disk "partitions" may exist. Is the goal to
find defined partitions or usable volumes?

http://www.sysinternals.com/ntw2k/freeware/psinfo.shtml
 
Randall said:
Hi there

i have to find out which partitions do exist on harddisk 0 on a large number
on computers.

found a way to do it with a script using diskpart unfortunately this does
not work on Windows NT.

i need the existing drive letters for this partitions on Windows NT 4.0 SP6
and Windows 2000 / XP...

does anyone know a way to get this info by WSH-Script, shell script or a
little command line tool?

Thanks in advance

set valid_drives=
for %%a in (
b c d e f g h i j k l m n o p q r s t u v w x y z
) do call :test %%a
echo Valid drives are: %valid_drives%
goto :EOF

:test
if exist %1: set valid_drives=%valid_drives% %1:
goto :EOF
 
Thanks for your help but maybe i didn't make 100% clear what i need to
do...

i need to find the partitions on only ONE drive ... in case some
computers have more then one haddisk...

psinfo will show me all available drives on all harddisks ....

for example computerA has 1 Harddisk with 2 partitons (c: and D:) i
need to get C: and D:

if computerB has 2 Harddisks with each 2 partitions (c:,D: on Disk0,
e:,f: on disk1) i need to get ONLY C: and D:

with diskpart it is easy to select just disk 0 and show the details but
unfortunately this does not work with Windows NT which is important ...

maybe you have another idea....
 
Thanks for your help but maybe i didn't make 100% clear what i
need to do...

i need to find the partitions on only ONE drive ... in case some
computers have more then one haddisk...

psinfo will show me all available drives on all harddisks ....

for example computerA has 1 Harddisk with 2 partitons (c: and D:)
i need to get C: and D:

if computerB has 2 Harddisks with each 2 partitions (c:,D: on
Disk0, e:,f: on disk1) i need to get ONLY C: and D:

Okay, but 2 HDs might have partitions seen by Windows as C: and D:...
or partitioned and formatted disk space not understood by Windows
(and not assigned a drive letter).
with diskpart it is easy to select just disk 0 and show the
details but unfortunately this does not work with Windows NT which
is important ...

maybe you have another idea....

I am on W2K w/o diskpart.exe.

Assuming this needs to found from a Win32 OS (CMD session and not a
bootable diskette/CD) I have no magic utility in mind. Many such
utilities will not function through Windows abstraction layers.
There may be many ways to get what you want with a simplicity of
which I am not aware. Perhaps others will post.

Having said that, have you considered
<path>msinfo32.exe /REPORT <path>\outfile.txt
IIRC msinfo32 was present in NT4 (?)
The report would contain lines like:
Partition Disk #0, Partition #0
Partition Disk #0, Partition #1
but again, only (I think) for recognized and mounted volumes.
 
Randall Flagg said:
Hi there

i have to find out which partitions do exist on harddisk 0 on a large number
on computers.

found a way to do it with a script using diskpart unfortunately this does
not work on Windows NT.

i need the existing drive letters for this partitions on Windows NT 4.0 SP6
and Windows 2000 / XP...

does anyone know a way to get this info by WSH-Script, shell script or a
little command line tool?

Thanks in advance
 
Randall Flagg said:
Hi there

i have to find out which partitions do exist on harddisk 0 on a large
number on computers.

found a way to do it with a script using diskpart unfortunately this
does not work on Windows NT.

i need the existing drive letters for this partitions on Windows NT
4.0 SP6 and Windows 2000 / XP...

does anyone know a way to get this info by WSH-Script, shell script or
a little command line tool?

Thanks in advance
Hi Randall,

you could use the Microsoft TechNet: Scriptomatic Tool
http://www.microsoft.com/technet/community/scriptcenter/tools/wmimatic.mspx
to generate a script which gathers information through wmi.
On nt this require the installation of

WMI CORE 1.5 for Windows NT 4.0
http://www.microsoft.com/downloads/release.asp?ReleaseID=18491

IMO the relevant keys are:
scriptomatic.hta(Win32_DiskDrive)
scriptomatic.hta(Win32_DiskPartition)
scriptomatic.hta(Win32_LogicalDisk)

scriptomatic.hta(Win32_OperatingSystem)

In msdn there is a page for win32_Volume but this isn't supported in
scriptomatic and since I'm a wsh newbie I'm stuck here.
http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_volume.asp

Based on logical drive/partition sizes you can _guess_ which partition
has what letter assigned. (On my system I've two equally sized disks
with the same partitioning scheme, so I've nothing to distinguish)

Sorry for my previous empty posting, tried to cancel with no success :-)
 
Matthias said:
Hi Randall,

you could use the Microsoft TechNet: Scriptomatic Tool
http://www.microsoft.com/technet/community/scriptcenter/tools/wmimatic
.mspx to generate a script which gathers information through wmi.
On nt this require the installation of

WMI CORE 1.5 for Windows NT 4.0
http://www.microsoft.com/downloads/release.asp?ReleaseID=18491

IMO the relevant keys are:
scriptomatic.hta(Win32_DiskDrive)
scriptomatic.hta(Win32_DiskPartition)
scriptomatic.hta(Win32_LogicalDisk)

scriptomatic.hta(Win32_OperatingSystem)

In msdn there is a page for win32_Volume but this isn't supported in
scriptomatic and since I'm a wsh newbie I'm stuck here.
http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_volume.asp

Based on logical drive/partition sizes you can guess which partition
has what letter assigned. (On my system I've two equally sized disks
with the same partitioning scheme, so I've nothing to distinguish)

Sorry for my previous empty posting, tried to cancel with no success
:-)


Thanks for your help... i found a little 'ready' script in scriptcenter
which does nearly exactly what i want.. maybe you want to have a look

ComputerName = "."
Set wmiServices = GetObject _
("winmgmts:{impersonationLevel=Impersonate}!//" & ComputerName)
Set wmiDiskDrives = wmiServices.ExecQuery _
("SELECT Caption, DeviceID FROM Win32_DiskDrive")

For Each wmiDiskDrive In wmiDiskDrives
WScript.Echo wmiDiskDrive.Caption & " (" & wmiDiskDrive.DeviceID &
")"
strEscapedDeviceID = _
Replace(wmiDiskDrive.DeviceID, "\", "\\", 1, -1, vbTextCompare)
Set wmiDiskPartitions = wmiServices.ExecQuery _
("ASSOCIATORS OF {Win32_DiskDrive.DeviceID=""" & _
strEscapedDeviceID & """} WHERE " & _
"AssocClass = Win32_DiskDriveToDiskPartition")

For Each wmiDiskPartition In wmiDiskPartitions
WScript.Echo vbTab & wmiDiskPartition.DeviceID
Set wmiLogicalDisks = wmiServices.ExecQuery _
("ASSOCIATORS OF {Win32_DiskPartition.DeviceID=""" & _
wmiDiskPartition.DeviceID & """} WHERE " & _
"AssocClass = Win32_LogicalDiskToPartition")

For Each wmiLogicalDisk In wmiLogicalDisks
WScript.Echo vbTab & vbTab & wmiLogicalDisk.DeviceID
Next
Next
Next

unfortunately i couldn't test it on a real NT machine today since i
don't have one here. tomorrow i'll be testing it.
tried it on a VMWare NT4 but there it didn't work..

since you say you are a wsh newbie maybe i can ask you something else...
i am starting to learn wsh myself but i still haven't found a decent
editor with step by step debugging. maybe you know one?

cheers...

randall
 
http://www.primalscript.com/

--
Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

:
| since you say you are a wsh newbie maybe i can ask you something else...
| i am starting to learn wsh myself but i still haven't found a decent
| editor with step by step debugging. maybe you know one?
|
| cheers...
|
| randall
 
Randall said:
unfortunately i couldn't test it on a real NT machine today since i
don't have one here. tomorrow i'll be testing it.
tried it on a VMWare NT4 but there it didn't work..

To be able to run WMI scripts on NT 4.0, you need to install
this one:

WMI CORE 1.5 for Windows NT 4.0
http://www.microsoft.com/downloads/release.asp?ReleaseID=18491

since you say you are a wsh newbie maybe i can ask you something else...
i am starting to learn wsh myself but i still haven't found a decent
editor with step by step debugging. maybe you know one?

I use PrimalScript
http://www.sapien.com/primalscript.htm

and Microsoft Windows Script Debugger
http://msdn.microsoft.com/library/default.asp?url=/downloads/list/webdev.asp


Here is a tutorial/demo with screen shots where PrimalScript Editor interfaces
with the Script Debugger:

http://www.sapien.com/tutorials/ScriptDebugger/tutorial_debugging.html
 
Would any of this code be helpful?

===============================================

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer _
& "\root\cimv2")

Set colDiskDrives = objWMIService.ExecQuery ("Select * from Win32_DiskDrive")

on error resume next

For each objDiskDrive in colDiskDrives


Wscript.Echo "Bytes Per Sector : " & objDiskDrive.BytesPerSector
Wscript.Echo "Caption : " & objDiskDrive.Caption
Wscript.Echo "Device ID : " & objDiskDrive.DeviceID
Wscript.Echo "Index : " & objDiskDrive.Index
Wscript.Echo "Interface Type : " & objDiskDrive.InterfaceType
Wscript.Echo "Media Type : " & objDiskDrive.MediaType
Wscript.Echo "Model : " & objDiskDrive.Model
Wscript.Echo "Name : " & objDiskDrive.Name
Wscript.Echo "Partitions : " & objDiskDrive.Partitions
Wscript.Echo "SCSI Bus : " & objDiskDrive.SCSIBus
Wscript.Echo "SCSI Logical Unit : " & objDiskDrive.SCSILogicalUnit
Wscript.Echo "SCSI Port : " & objDiskDrive.SCSIPort
Wscript.Echo "SCSI TargetId : " & objDiskDrive.SCSITargetId
Wscript.Echo "Size : " & objDiskDrive.Size

' Wscript.Echo "Sectors Per Track: " & vbTab & _
' objDiskDrive.SectorsPerTrack
' Wscript.Echo "Signature: " & vbTab & objDiskDrive.Signature
' Wscript.Echo "PNP DeviceID: " & vbTab & objDiskDrive.PNPDeviceID
' Wscript.Echo "Manufacturer: " & vbTab & objDiskDrive.Manufacturer
' Wscript.Echo "Media Loaded: " & vbTab & objDiskDrive.MediaLoaded
' Wscript.Echo "Status: " & vbTab & objDiskDrive.Status
' Wscript.Echo "Total Cylinders: " & vbTab & _
' objDiskDrive.TotalCylinders
' Wscript.Echo "Total Heads: " & vbTab & objDiskDrive.TotalHeads
' Wscript.Echo "Total Sectors: " & vbTab & objDiskDrive.TotalSectors
' Wscript.Echo "Total Tracks: " & vbTab & objDiskDrive.TotalTracks
' Wscript.Echo "Tracks Per Cylinder: " & vbTab & _
' objDiskDrive.TracksPerCylinder

' For i = Lbound(objDiskDrive.Capabilities) to Ubound(objDiskDrive.Capabilities)
' Wscript.Echo "Capabilities: " & vbTab & objDiskDrive.Capabilities(i)
' Next

wscript.echo
Next

===============================================


--
And always try the MS KB first before posting.
The answer is probably already posted.
MS KB: http://support.microsoft.com/default.aspx?scid=fh;EN-US;KBHOWTO
----
Mark-Allen Perry
ALPHA Systems
Marly, Switzerland
mark-allen_AT_mvps_DOT_org

Hi there

i have to find out which partitions do exist on harddisk 0 on a large number
on computers.

found a way to do it with a script using diskpart unfortunately this does
not work on Windows NT.

i need the existing drive letters for this partitions on Windows NT 4.0 SP6
and Windows 2000 / XP...

does anyone know a way to get this info by WSH-Script, shell script or a
little command line tool?

Thanks in advance
 
Back
Top