I try to list all windows user using this code but it throws exception of invalid query , I am using win vista.
the code:
Expand|Select|Wrap|Line Numbers
- try
- {
- SelectQuery sQuery = new SelectQuery("Win32_UserAccount","Domain=’ALI-PC’");
- ManagementObjectSearcher mSearcher = new ManagementObjectSearcher(sQuery);
- // String[] winUsers = null;
- int i = 0;
- foreach (ManagementObject mObject in mSearcher.Get())
- {
- // winUsers[i] = ((String)mObject["Name"]);
- // MessageBox.Show(winUsers[i]);
- i++;
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.ToString());
- }