wmi

Get the total amount of pages from Win32_PrintJob

早过忘川 提交于 2020-01-21 03:48:05
问题 The Win32_PrintJob WMI class has lots of properties. (see: Win32_PrintJob on MSDN) I have a small .NET application that poles the printing jobs and displays the jobs' information. The TotalPages propery gives the amount of pages sent. But that figure DOESN'T take into account the number of copies requested by the user. So, if a user wants to print 5 copies of a two page document, the value of TotalPages will be 2, not 10. How can i get the number of copies for a printing job, or get the total

How do i get info about recently connected usb device

别等时光非礼了梦想. 提交于 2020-01-20 07:04:04
问题 I can catch when usb device is connected with Win32_DeviceChangeEvent but there are only 3 properties allowed to view class Win32_DeviceChangeEvent : __ExtrinsicEvent { uint8 SECURITY_DESCRIPTOR[]; uint64 TIME_CREATED; uint16 EventType; }; But i don't understand how to get all info about this device. Specifically, its port and hub, VirtualHubAdress Name and etc. public enum EventType { Inserted = 2, Removed = 3 } public static void RegisterUsbDeviceNotification() { var watcher = new

WMI returns information in different formats

爷,独闯天下 提交于 2020-01-17 11:17:52
问题 I want to read the hardware configuration to check if a license for my software is valid. Currently, I tried using WMI . This works fine on many machines for several weeks but sometimes, without an obvious reason, WMI returns the hardware configuration in a different format. For example, the serial number of the primary hard disc is converted from characters to a hex string, with all character hex values being swapped pair wise. I figured out that different Windows user types (admin/normal)

connect to Remote server in vb script

纵然是瞬间 提交于 2020-01-17 06:14:15
问题 hi i have tried to connect to remote server in vbscript but i am getting the error 2147023174 RPC server is not available. if tried to connect via remote desktop connection i am able to connect.please help me to reslove this issue. enter code here Dim strMachine="IP" strAltDomain = "domail" strAltUsername = "username" strAltPwd ="*****" Set objGlobalCIMV2Service = objSWbemLocator.ConnectServer(strMachine, _ "root\cimv2", strAltUsername, strAltPwd, "MS_409", "ntlmdomain:" + strAltDomain)

Why new ManagementObject(@“root\WMI”, “BcdStore”, null) throws exception?

狂风中的少年 提交于 2020-01-17 04:49:17
问题 Using WMI Code Creator , I'm trying to issue a call to root\WMI\BcdStore.EnumerateObjects() . However I get an exception on the first line of code: var classInstance = new ManagementObject( @"root\WMI", "BcdStore", null); // <== exception!!! // Obtain in-parameters for the method var inParams = classInstance.GetMethodParameters("EnumerateObjects"); // ... The exception is: A first chance exception of type 'System.ArgumentOutOfRangeException' occurred in System.Management.dll Additional

Set administrative privileges in C#

十年热恋 提交于 2020-01-17 01:44:10
问题 I have been writing many scripts using WMI and a lot of them only work if I start visual studio with "Run as Administrator". Is there a way to set that programmatically with .Net or other means? Eventually, these scripts will be run as .exes from Unity3D so I need to automate setting these rights before running them. Ideally I'm hoping this can all be done in C#. 回答1: This question was answered in the comments. The only way is to add a manifest file to your project that sets the required

WMI常见问题及解决方法

只谈情不闲聊 提交于 2020-01-16 02:31:32
一. 常见问题及解决方法 1. 当通过WMI添加服务器、Microsoft .NET、Exchange服务器时,提示“验证失败。请确认用户名和密码”。 解决方法: 请以<domainname>\<username>格式输入用户名 注意: OpManger中对于本地WMI验证,不需要输入用户名和密码。 2. 当以WMI模式监控Windows服务器时,内存利用率数据显示错误。 解决方法: 在WMI中,我们使用Win32_OperatingSystem获取Windows2003服务器的内存数据。在系统内存超过4GB时,则不能报告准确的信息。这是Windows 2003 SP1的一个问题。请参阅 http://support.microsoft.com/kb/906868/ 了解更多信息,并安装补丁。 3. 如何重建WMI类? 解决方法: MOF (受管理对象格式)文件是一个机制,通过它关于WMI类的信息进入WMI存储库。存储库中的类定义可能损坏,这种情况下, 重新编译MOF文件,用最初安装操作系统时的类定义将其复写和替换。 在命令提示符执行以下命令: Windows 2003/XP * c:\windows\system32\wbem\Mofcomp.exe c:\windows\system32\wbem\cimwin32.mof * c:\windows\system32\wbem

Starting with window application for retriving list of software and hardware installed on remote pc

你离开我真会死。 提交于 2020-01-16 01:08:34
问题 I want to create an application that can give me a description of all the softwares and hardware installed on a computer that is connected through a Local Network. In Hardware Description - I want something like the list shown in Device manager and in software description i want a list of all the softwares installed in remote pc as shown in "add and remove programs". How should i start for this. What i need to implement. I havent used any API before so plz be little descriptive so that i can

Check for process owner on remote machine and kill it when owner is xyz

ぐ巨炮叔叔 提交于 2020-01-14 19:51:09
问题 Hey I want to check on an remote computer for a process owner of a specific process and kill it when the owner is for example xyz. I already managed it to check for the owner but I don't know how to kill it when the owner is xyz. What I have so far: get-wmiobject -computername remotePC win32_process|where{$_.name -eq "firefox.exe"}|select name,@{n="owner";e={$_.getowner().user}} 回答1: Get-WmiObject -Class Win32_Process -Filter "Name='firefox.exe'" -ComputerName remotePC | Where-Object { $_

WMI: Get list of all serial (COM) ports including virtual ports

喜夏-厌秋 提交于 2020-01-14 05:20:07
问题 I'm currently working on a little C# program to interact with an Arduino microcontroller. The program has a combobox where you can choose the COM-port. The µc is connected by USB and a virtual COM-port (CH340). I use the code below to fill in the avaible COM-ports to the combobox. private void Form1_Load(object sender, EventArgs e) { string[] PortNames = SerialPort. GetPortNames(); comboBoxPort.Items.AddRange(PortNames); } The downside of this is, you have to take a look into the Device