473,396 Members | 1,924 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Can't get a list of printers??

J
Hello,

I'm using the following snippet of code to try and get a list of all the
printers installed on this machine. I have installed some network printers
on this machine and they just won't show up! This is in a webservice method,
if that makes any differance.

Also, when I change the query to "Select * from Win32_Process" I do return
many processes, any ideas to what might be causing this?

J

ManagementObjectCollection oReturnCollection;

System.Management.ManagementScope oMs = new
System.Management.ManagementScope("root\\CIMV2");
System.Management.ObjectQuery oQuery = new
System.Management.ObjectQuery("select * from Win32_Printer");

//Execute the query

ManagementObjectSearcher oSearcher = new
ManagementObjectSearcher(oMs,oQuery);

//Get the results

oReturnCollection = oSearcher.Get();

//loop through found drives and write out info

foreach( ManagementObject oReturn in oReturnCollection )

{

// Printer name

output = output + "<printer>" + "Name : " + oReturn["Name"].ToString() +
"</printer>" ;

}
Nov 23 '05 #1
2 4765
Since this is a webservice delegation can be an issue for this connection to
succeed in retrieving the data.

See a description for the Delegation Impersonation Level with regards to WMI
to understand the problem. You will also need to trust the computer account
for delegation operations on the machine that you are connecting to. The
difference here between processes and printers is that the printers are
installed off of a remote print server.

This link can probably get you started.
http://www.microsoft.com/technet/scr...ifaq.mspx#EEAA

--
Scott McNairy
Microsoft MVP - Windows Server Management Infrastructure
"J" <A@b.c> wrote in message news:ui**************@TK2MSFTNGP09.phx.gbl...
Hello,

I'm using the following snippet of code to try and get a list of all
the printers installed on this machine. I have installed some network
printers on this machine and they just won't show up! This is in a
webservice method, if that makes any differance.

Also, when I change the query to "Select * from Win32_Process" I do return
many processes, any ideas to what might be causing this?

J

ManagementObjectCollection oReturnCollection;

System.Management.ManagementScope oMs = new
System.Management.ManagementScope("root\\CIMV2");
System.Management.ObjectQuery oQuery = new
System.Management.ObjectQuery("select * from Win32_Printer");

//Execute the query

ManagementObjectSearcher oSearcher = new
ManagementObjectSearcher(oMs,oQuery);

//Get the results

oReturnCollection = oSearcher.Get();

//loop through found drives and write out info

foreach( ManagementObject oReturn in oReturnCollection )

{

// Printer name

output = output + "<printer>" + "Name : " + oReturn["Name"].ToString() +
"</printer>" ;

}

Nov 23 '05 #2
Since this is a webservice delegation can be an issue for this connection to
succeed in retrieving the data.

See a description for the Delegation Impersonation Level with regards to WMI
to understand the problem. You will also need to trust the computer account
for delegation operations on the machine that you are connecting to. The
difference here between processes and printers is that the printers are
installed off of a remote print server.

This link can probably get you started.
http://www.microsoft.com/technet/scr...ifaq.mspx#EEAA

--
Scott McNairy
Microsoft MVP - Windows Server Management Infrastructure
"J" <A@b.c> wrote in message news:ui**************@TK2MSFTNGP09.phx.gbl...
Hello,

I'm using the following snippet of code to try and get a list of all
the printers installed on this machine. I have installed some network
printers on this machine and they just won't show up! This is in a
webservice method, if that makes any differance.

Also, when I change the query to "Select * from Win32_Process" I do return
many processes, any ideas to what might be causing this?

J

ManagementObjectCollection oReturnCollection;

System.Management.ManagementScope oMs = new
System.Management.ManagementScope("root\\CIMV2");
System.Management.ObjectQuery oQuery = new
System.Management.ObjectQuery("select * from Win32_Printer");

//Execute the query

ManagementObjectSearcher oSearcher = new
ManagementObjectSearcher(oMs,oQuery);

//Get the results

oReturnCollection = oSearcher.Get();

//loop through found drives and write out info

foreach( ManagementObject oReturn in oReturnCollection )

{

// Printer name

output = output + "<printer>" + "Name : " + oReturn["Name"].ToString() +
"</printer>" ;

}

Nov 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Mike Tammerman | last post by:
Hi, I want to get the printer list from CUPS. I found some ways using lpstat -p and http://localhost:631/printers but, these ways require some parsing and I am not sure, if the parsing...
5
by: Prakash T. | last post by:
Dear friends, This is Prakash from in India at tamilnadu. I am a MCA Student. Please answer the Que: Mention the type of applications which can be developed using C language? Thanks and...
0
by: Dexter | last post by:
Hello all, I need to list in a dropdownlist, all network printers. I have a server with 6 printers, and I need to do a direct print at printer that the user to select in a dropdownlist. ...
0
by: J | last post by:
Hello, I'm using the following snippet of code to try and get a list of all the printers installed on this machine. I have installed some network printers on this machine and they just won't...
1
by: gnusmsa | last post by:
ASP.NET 2.0 (C#) application Using Windows authentication and impersonation Windows Server 2003 (IIS6) Server is a member server on a domain Logged into server as a domain user that is in the...
1
by: Bob | last post by:
Greetings, I have a written an app that checks to see what printers are available to a machine, it then populates a combobox and allows the user to choose any of the printers. Basically I...
2
by: calan_svc | last post by:
I have a dll I wrote in VB6. Basically, it can list all the printers it finds as well as print to a selected printer. I created a test app in VB6, added the dll as a reference, and added the...
0
by: Ravigwipro | last post by:
Hi, I m able to get the printers object to know what are the printers had been installed and all. here my requirement is i have to write a data from VB to MS Word. for the page setup i have to...
2
by: smartic | last post by:
i'm having three lists when i select from any one the others be visible by hierarchy but it takes to long to write my code is there is another away to write this code like XML that is my javascript...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.