whorsfall
asked on
SWbemObject.GetObjectText_ C# Equivilent?
Hi,
Is there an equivilent to the following object:
http://msdn.microsoft.com/en-us/library/aa393775%28v=vs.85%29.aspx
SWbemObject.GetObjectText_ Method
So in VBScript this would output something like:
' ----- Script start ------
Option Explicit
Dim objWMIService, objItem, colItems, strComputer
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("S elect * from Win32_LogicalDisk")
For Each objItem in colItems
WScript.Echo objItem.getObjectText_
Next
WSCript.Quit
' ----- Script end ------------
instance of Win32_LogicalDisk
{
Access = 0;
Caption = "C:";
Compressed = FALSE;
CreationClassName = "Win32_LogicalDisk";
Description = "Local Fixed Disk";
DeviceID = "C:";
DriveType = 3;
FileSystem = "NTFS";
FreeSpace = "27016232960";
MaximumComponentLength = 255;
MediaType = 12;
Name = "C:";
QuotasDisabled = TRUE;
QuotasIncomplete = FALSE;
QuotasRebuilding = FALSE;
Size = "53684989952";
SupportsDiskQuotas = TRUE;
SupportsFileBasedCompressi on = TRUE;
SystemCreationClassName = "Win32_ComputerSystem";
SystemName = "LEVEL3";
VolumeDirty = FALSE;
VolumeName = "OS";
VolumeSerialNumber = "8CBC64AB";
};
So it would format the text like it does using WbemTest.
So I am looking for the C# equivilent of:
WScript.Echo objItem.getObjectText_
Thanks,
Ward.
Is there an equivilent to the following object:
http://msdn.microsoft.com/en-us/library/aa393775%28v=vs.85%29.aspx
SWbemObject.GetObjectText_
So in VBScript this would output something like:
' ----- Script start ------
Option Explicit
Dim objWMIService, objItem, colItems, strComputer
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("S
For Each objItem in colItems
WScript.Echo objItem.getObjectText_
Next
WSCript.Quit
' ----- Script end ------------
instance of Win32_LogicalDisk
{
Access = 0;
Caption = "C:";
Compressed = FALSE;
CreationClassName = "Win32_LogicalDisk";
Description = "Local Fixed Disk";
DeviceID = "C:";
DriveType = 3;
FileSystem = "NTFS";
FreeSpace = "27016232960";
MaximumComponentLength = 255;
MediaType = 12;
Name = "C:";
QuotasDisabled = TRUE;
QuotasIncomplete = FALSE;
QuotasRebuilding = FALSE;
Size = "53684989952";
SupportsDiskQuotas = TRUE;
SupportsFileBasedCompressi
SystemCreationClassName = "Win32_ComputerSystem";
SystemName = "LEVEL3";
VolumeDirty = FALSE;
VolumeName = "OS";
VolumeSerialNumber = "8CBC64AB";
};
So it would format the text like it does using WbemTest.
So I am looking for the C# equivilent of:
WScript.Echo objItem.getObjectText_
Thanks,
Ward.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Did you check this link: (ManagementObjectSearcher Class)
http://www.codeproject.com/KB/system/DeviceStatus.aspx