Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Enumerate hard disks, exclude partitions
#31
you don't need the batch file at all stop using it and use a txt file like i showed you

the only reason we are using a txt file is that is how you do multiple commands in diskpart but a Batch file is not needed at all  for qm

this function shows  all drives not just hd's


Code:
Copy      Help
dll kernel32 #GetLogicalDrives
dll kernel32 #GetDriveType $nDrive
int i dt dm
str s(" :\") s2
dm=GetLogicalDrives ;;32-bit mask of available drives
for i 0 32
,if(dm>>i&1)
,,s[0]='A'+i
,,dt=GetDriveType(s); if(dt>6) dt=0
,,s2.getl("UNKNOWN[]NO_ROOT_DIR[]REMOVABLE[]FIXED[]REMOTE[]CDROM[]RAMDISK" dt)
,,out "%s %s" s s2

or here is a c# function tht will pretty much give you all the info on all your drives uses wmi
would need to simply this as there is way more info than you need


Function GetDriveAndPartitionInfoWMI 
Code:
Copy      Help
str code=
;using System;
;using System.Management;
;using System.Windows.Forms;
;namespace WMISample
;{
;;;;public class MyWMIQuery
;;;;{
;;;;;;;;public static void Main()
;;;;;;;;{
;;;;;;;;;;;;try
;;;;;;;;;;;;{
;;;;;;;;;;;;;;;;ManagementObjectSearcher searcher =
;;;;;;;;;;;;;;;;;;;;new ManagementObjectSearcher("root\\CIMV2",
;;;;;;;;;;;;;;;;;;;;"SELECT * FROM Win32_DiskPartition");
;;;;;;;;;;;;;;;;foreach (ManagementObject queryObj in searcher.Get())
;;;;;;;;;;;;;;;;{
;;;;;;;;;;;;;;;;;;;;Console.WriteLine("-----------------------------------");
;;;;;;;;;;;;;;;;;;;;Console.WriteLine("Win32_DiskPartition instance");
;;;;;;;;;;;;;;;;;;;;Console.WriteLine("-----------------------------------");
;;;;;;;;;;;;;;;;;;;;Console.WriteLine("Access: {0}", queryObj["Access"]);
;;;;;;;;;;;;;;;;;;;;Console.WriteLine("Availability: {0}", queryObj["Availability"]);
;;;;;;;;;;;;;;;;;;;;Console.WriteLine("BlockSize: {0}", queryObj["BlockSize"]);
;;;;;;;;;;;;;;;;;;;;Console.WriteLine("Bootable: {0}", queryObj["Bootable"]);
;;;;;;;;;;;;;;;;;;;;Console.WriteLine("BootPartition: {0}", queryObj["BootPartition"]);
;;;;;;;;;;;;;;;;;;;;Console.WriteLine("Caption: {0}", queryObj["Caption"]);
;;;;;;;;;;;;;;;;;;;;Console.WriteLine("ConfigManagerErrorCode: {0}", queryObj["ConfigManagerErrorCode"]);
;;;;;;;;;;;;;;;;;;;;Console.WriteLine("ConfigManagerUserConfig: {0}", queryObj["ConfigManagerUserConfig"]);
;;;;;;;;;;;;;;;;;;;;Console.WriteLine("CreationClassName: {0}", queryObj["CreationClassName"]);
;;;;;;;;;;;;;;;;;;;;Console.WriteLine("Description: {0}", queryObj["Description"]);
;;;;;;;;;;;;;;;;;;;;Console.WriteLine("DeviceID: {0}", queryObj["DeviceID"]);
;;;;;;;;;;;;;;;;;;;;Console.WriteLine("DiskIndex: {0}", queryObj["DiskIndex"]);
;;;;;;;;;;;;;;;;;;;;Console.WriteLine("ErrorCleared: {0}", queryObj["ErrorCleared"]);
;;;;;;;;;;;;;;;;;;;;Console.WriteLine("ErrorDescription: {0}", queryObj["ErrorDescription"]);
;;;;;;;;;;;;;;;;;;;;Console.WriteLine("ErrorMethodology: {0}", queryObj["ErrorMethodology"]);
;;;;;;;;;;;;;;;;;;;;Console.WriteLine("HiddenSectors: {0}", queryObj["HiddenSectors"]);
;;;;;;;;;;;;;;;;;;;;Console.WriteLine("Index: {0}", queryObj["Index"]);
;;;;;;;;;;;;;;;;;;;;Console.WriteLine("InstallDate: {0}", queryObj["InstallDate"]);
;;;;;;;;;;;;;;;;;;;;Console.WriteLine("LastErrorCode: {0}", queryObj["LastErrorCode"]);
;;;;;;;;;;;;;;;;;;;;Console.WriteLine("Name: {0}", queryObj["Name"]);
;;;;;;;;;;;;;;;;;;;;Console.WriteLine("NumberOfBlocks: {0}", queryObj["NumberOfBlocks"]);
;;;;;;;;;;;;;;;;;;;;Console.WriteLine("PNPDeviceID: {0}", queryObj["PNPDeviceID"]);
;;;;;;;;;;;;;;;;;;;;if(queryObj["PowerManagementCapabilities"] == null)
;;;;;;;;;;;;;;;;;;;;;;;;Console.WriteLine("PowerManagementCapabilities: {0}", queryObj["PowerManagementCapabilities"]);
;;;;;;;;;;;;;;;;;;;;else
;;;;;;;;;;;;;;;;;;;;{
;;;;;;;;;;;;;;;;;;;;;;;;UInt16[] arrPowerManagementCapabilities = (UInt16[])(queryObj["PowerManagementCapabilities"]);
;;;;;;;;;;;;;;;;;;;;;;;;foreach (UInt16 arrValue in arrPowerManagementCapabilities)
;;;;;;;;;;;;;;;;;;;;;;;;{
;;;;;;;;;;;;;;;;;;;;;;;;;;;;Console.WriteLine("PowerManagementCapabilities: {0}", arrValue);
;;;;;;;;;;;;;;;;;;;;;;;;}
;;;;;;;;;;;;;;;;;;;;}
;;;;;;;;;;;;;;;;;;;;Console.WriteLine("PowerManagementSupported: {0}", queryObj["PowerManagementSupported"]);
;;;;;;;;;;;;;;;;;;;;Console.WriteLine("PrimaryPartition: {0}", queryObj["PrimaryPartition"]);
;;;;;;;;;;;;;;;;;;;;Console.WriteLine("Purpose: {0}", queryObj["Purpose"]);
;;;;;;;;;;;;;;;;;;;;Console.WriteLine("RewritePartition: {0}", queryObj["RewritePartition"]);
;;;;;;;;;;;;;;;;;;;;Console.WriteLine("Size: {0}", queryObj["Size"]);
;;;;;;;;;;;;;;;;;;;;Console.WriteLine("StartingOffset: {0}", queryObj["StartingOffset"]);
;;;;;;;;;;;;;;;;;;;;Console.WriteLine("Status: {0}", queryObj["Status"]);
;;;;;;;;;;;;;;;;;;;;Console.WriteLine("StatusInfo: {0}", queryObj["StatusInfo"]);
;;;;;;;;;;;;;;;;;;;;Console.WriteLine("SystemCreationClassName: {0}", queryObj["SystemCreationClassName"]);
;;;;;;;;;;;;;;;;;;;;Console.WriteLine("SystemName: {0}", queryObj["SystemName"]);
;;;;;;;;;;;;;;;;;;;;Console.WriteLine("Type: {0}", queryObj["Type"]);
;;;;;;;;;;;;;;;;}
;;;;;;;;;;;;}
;;;;;;;;;;;;catch (ManagementException e)
;;;;;;;;;;;;{
;;;;;;;;;;;;;;;;MessageBox.Show("An error occurred while querying for WMI data: " + e.Message);
;;;;;;;;;;;;}
;;;;;;;;}
;;;;}
;}
CsExec(code)


Messages In This Thread
Enumerate hard disks, exclude partitions - by win - 09-08-2018, 09:34 PM
RE: Enumerate hard disks, exclude partitions - by Kevin - 09-09-2018, 10:38 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)