TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Paul
NA
3
0
How to get remote HD size for c:\
Jun 18 2010 9:38 AM
Looking for a way to remotely grab the HD size of a machine on the network. Here is what I'm trying but it isn't working.
My method works for pulling everything else I need but getting hd size i am not having any luck.
string hdSize = GetNetScan("Win32_DiskDrive", "DeviceID=\"c:\"", un, pass, oc1, oc2, oc3, oc4);
public static string GetNetScan(string strTable, string strProps, string un, string pass, byte oc1, byte oc2, byte oc3, byte oc4)
{
try
{
ConnectionOptions options = new ConnectionOptions();
options.Username = un;
options.Password = pass;
options.EnablePrivileges = true;
options.Impersonation = ImpersonationLevel.Impersonate;
ManagementScope scope;
scope = new ManagementScope("\\\\" + oc1 + "." + oc2 + "." + oc3 + "." + oc4 + "\\root\\cimv2", options);
scope.Connect();
String queryString = "SELECT " + strProps + " FROM " + strTable + "";
ObjectQuery query;
query = new ObjectQuery(queryString);
ManagementObjectSearcher objOS = new ManagementObjectSearcher(scope, query);
string strInfo = string.Empty;
foreach (ManagementObject MO in objOS.Get())
foreach (PropertyData pd in MO.Properties)
strInfo += pd.Value + ",";
return strInfo.Substring(0, strInfo.Length - 1);
}
catch (Exception exc)
{
}
return "na";
}
Reply
Answers (
0
)
Object recognition through csharp
How to Make a button to Accept keyboard "Enter" Press