Printer Status over Network

T

TARUN

Hello all,

Please help and suggest the code to get the printer status over the
network.
for Example, i have an string "\\\\os1\\PtName"

where os1 is the system name
and PtName is the printer name

I need to know the status of this printer on the system name "os1".
Please suggest me the code for that in C#.

I am using WMI but not able to get anything helpful stuff.


Thank's and Regards
Tarun Sinha
 
N

Nicholas Paldino [.NET/C# MVP]

Tarun,

What is the query you are using in WMI? Is the printer available from
the local machine, or no? If it is not, then I don't think you can get the
printer information (the WMI providers work on the local machine). I think
you would have to connect to the WMI provider on "os1" and then run the
query there.
 
T

TARUN

Thank's for reply

Yes i am able get the local machine printer information with the help
of WMI,
and here is the code :


ManagementScope mgmtscope = new ManagementScope(@"\root
\cimv2");
mgmtscope.Connect();
ManagementObjectSearcher objSearcher = new
ManagementObjectSearcher("Select * from Win32_Printer");


foreach (ManagementObject printer in objSearcher.Get())
{
sysName =
printer["SystemName"].ToString().ToLower();
printerName =
printer["Name"].ToString().ToLower();
}


I also tried
select * from win32_printer where servername = '\\os1'
but still not able to get the printer info on system name os1.


any idea ???
waiting for your reply ..............................

Thank's
Tarun sinha



Tarun,

What is the query you are using in WMI? Is the printer available from
the local machine, or no? If it is not, then I don't think you can get the
printer information (the WMI providers work on the local machine). I think
you would have to connect to the WMI provider on "os1" and then run the
query there.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)




Hello all,
Please help and suggest the code to get the printer status over the
network.
for Example, i have an string "\\\\os1\\PtName"
where os1 is the system name
and PtName is the printer name
I need to know the status of this printer on the system name "os1".
Please suggest me the code for that in C#.
I am using WMI but not able to get anything helpful stuff.
Thank's and Regards
Tarun Sinha- Hide quoted text -

- Show quoted text -
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top