By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,864 Members | 1,265 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,864 IT Pros & Developers. It's quick & easy.

Printer Status over Network

P: n/a
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

Jul 31 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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]
- mv*@spam.guard.caspershouse.com

"TARUN" <ta*********@gmail.comwrote in message
news:11**********************@d30g2000prg.googlegr oups.com...
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
Aug 1 '07 #2

P: n/a
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

On Aug 1, 8:08 am, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
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]
- m...@spam.guard.caspershouse.com

"TARUN" <tarun.si...@gmail.comwrote in message

news:11**********************@d30g2000prg.googlegr oups.com...
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 -

Aug 1 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.