list of printers on a 64 bit remote machine
What is the best way to get the list of printers on a 64 bit remote machine?
I can successfully use, WMI on a 32 bit remote machine but not a 64 bit remote machine. So I wonder if there is an alternative way to WMI to get this list from a remote 64 bit machine?
Thanks
Re: list of printers on a 64 bit remote machine
How are you enumerating the printers, via a registry key or calling the win32_printer class?
Re: list of printers on a 64 bit remote machine
Re: list of printers on a 64 bit remote machine
I just tried some code and managed to successfully return printers from a 64-bit Vista Enterprise machine from my XP SP2 32-bit machine..
What error/results are you seeing?
Re: list of printers on a 64 bit remote machine
Error is:
Access denied. It seems it does not like my login details.
Please note that the login has admin rights.
The code works fine for accessing all machines from my 32 bit machine but get access denied on the 64 bit sp2 machines.
It seems the code is fine and there is something to do with the access rights permission on that issue machines.
I have checked an my login is indeed added as admin there.
Not sure where to look now.
I even get the same access denied error when using wmi code generator.
In case you would like to see my code:
//list of remote printers...
string strServer = "\\\\" + txtServerName.Text;
ConnectionOptions options = new ConnectionOptions();
options.Impersonation = ImpersonationLevel.Impersonate;
options.EnablePrivileges = true;
options.Username = "mydomain\\user";
options.Password = "password";
ManagementScope myScope = new ManagementScope(strServer + "\\root\\cimv2", options);
SelectQuery oQuery = new SelectQuery("SELECT * FROM WIN32_Printer");
ManagementObjectSearcher oResults = new ManagementObjectSearcher(myScope, oQuery);
//Iterate through printers...
foreach (ManagementObject oItem in oResults.Get())
{
string strPrinterName = oItem.Properties["DeviceID"].Value.ToString();
}
Thanks
Re: list of printers on a 64 bit remote machine
hello again,
Does my code above look ok to you?
Does it make a difference whether I am accessing a 32 bit or 64 bit remote machine?
Thanks
Re: list of printers on a 64 bit remote machine
Hmm.. Must be permissions related then. Just tried it here with no issues... There is probably a local, or group policy setting forbidding it
Re: list of printers on a 64 bit remote machine
Did you run my code?
Not sure where to check for these settings.
Re: list of printers on a 64 bit remote machine
Your code is exactly identical to mine (albeit mine is in VB.NET) but the only way I can get an access denied is by removing myself from the Admins group of a test machine.
I do not have a XP SP2 64-bit machine to hand to see if something is buggy there.
have you tried logging on to the machine in question to see whether you actually get an administrative token (i.e. can do things only administrators can, like accessing the user accounts icon in Control Panel)