English 中文(简体)
How to fix the Win32_Printer.Default field so that it returns the correct value when using WMI remotely?
原标题:

The Win32_Printer class returns a field per printer called Default (a boolean value). This works locally and accurately returns the Default printer. However when remotely connecting in with WMI, it always returns false.

I thought it could depend on the user with which you did the remote WMI query. However, that s not the case (I tried it with different users and no change).

Is there anyway to fix this? I m currently trying to get this to work on a Windows 7 client and i m connecting to it from a Windows 2008 R2

问题回答

I can see that this thread is quite old but I thought I d add my 2 cents worth even if though it s of no help, but this same issue is there with XP too. In fact under XP you can t read the Win32_CDROMDrive stuff either, although it s fixed under Windows 7.

Have you found an answer to the default printer issue with WMI? As an alternative you can read the default printer but not the port from the registry as in: hkcusoftwaremicrosoftwindows NTCurrentVersionWindowsDevice

It ll show something like HP Color LaserJet CP3525 PCL6,winspool,Ne03: Trim the crap and you ve got what you need. Now you ve got the printer you can get the matching port via WMI.

Regards,

4Eyes





相关问题
How can I query NTFS disk quotas in C#?

I need to be able to find, for all users on a given remote machine, those users disk quotas and actual disk usage. I need to be able to do this reporting in a C# application. (Well, technically a DLL ...

WMI Poor Performance

I wrote a code in C# that maps logical drives to their physical disks, using WMI (System.Management). The code working perfectly, but slow like hell. In my machine (Windows 7 x64, Dual-Core with 3 GB ...

Closing Open Files using C#

I have a situation where people are connected to files on a share and it s blocking me from overwriting the file. I m trying to write a method that will look to see if a filePath that I provide is ...

Binding an SSL certificate to a port programmatically

I m working on a self-hosted WCF service for which encrypted communications is an option. Everything works fine when a certificate is already bound to the port as described here. However, I want to ...

热门标签