I'm trying to get information about all the print jobs on a certain
printer on a certain server. The attached code will return the jobs
for all printers on a server, it seems the RelativePath property is
being ignored!
I'd be grateful if anyone could help as its driving me MAD.
ta
Si
--------------
static void JobsOnPrinter()
{
ManagementPath manPath = new ManagementPath();
manPath.NamespacePath = @"root\CIMV2";
manPath.Server = "Server";
manPath.RelativePath = "Win32_Printer.DeviceID='Printer'";
ManagementScope manScope = new ManagementScope(manPath);
System.Management.ObjectQuery printQuery = new
System.Management.ObjectQuery("SELECT * FROM Win32_PrintJob");
ManagementObjectSearcher printSearch = new
ManagementObjectSearcher(manScope, printQuery);
ManagementObjectCollection printCollection = printSearch.Get();
foreach( ManagementObject job in printCollection )
{
Console.WriteLine("===========================================");
Console.WriteLine("Printer : " + job["Name"].ToString());
Console.WriteLine("Doc : " + job["Document"].ToString());
Console.WriteLine("Status : " + job["StatusMask"].ToString());
}
}
We use instead
ManagementScope manScope = new ManagementScope(manPath.RelativePath);
Thanks
Jian Shen
This posting is provided "AS IS" with no warranties, and confers no rights.
"Jian-Shen Lin[MS]" <js...@online.microsoft.com> wrote in message news:OFBPJisC...@cpmsftngxa06.phx.gbl...
I tried this,
string relPath =
@"\\ps\root\CIMV2:Win32_Printer.DeviceID='TP2'";
ManagementScope manScope = new ManagementScope(relPath);
which produced the same results as before. I guess what
Andy says in his reply is correct and RelativePath is not
involved.
thanks again
Simon
Any other suggestions would be greatly accepted, otherwise
I'll go back to using ads.
Thanks
Si
Scott
In article <013701c30d62$cd66ac40$3301...@phx.gbl>, "Si" says...
"Si" <simon....@herbertsmith.com> wrote in message news:017c01c30d64$76563e00$2f01...@phx.gbl...
"Dan" <danj...@yahoo.com> wrote in message news:fa556b4d.03042...@posting.google.com...