Click here to Skip to main content
15,892,674 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
I am using WMI management object for checking the status of printer availability. I am generic failure error. My machine is Windows 2003 server. I am attaching the code snippet here

ConnectionOptions objConnection = new ConnectionOptions();
            
string strMachineName = System.Environment.MachineName;
ManagementScope objScope = new ManagementScope(@"\\" + strMachineName + @"\root\cimv2");//, objConnection);
objScope.Connect(); (Getting a generic failure error at this line)
SelectQuery selectQuery = new SelectQuery();
selectQuery.QueryString = "Select * from win32_Printer";
ManagementObjectSearcher MOS = new ManagementObjectSearcher(objScope, selectQuery);
ManagementObjectCollection MOC = MOS.Get();


Best Regards
Surya

[Edit]Code is Wrapped in "pre" tags[/Edit]
Posted
Updated 11-Jan-11 17:45pm
v2
Comments
Kasson 11-Jan-11 23:09pm    
Are you connecting the printer on network or in your system.

1 solution

Hope WMI PRINTER[^] will give you an idea.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900