wmi

How to get methods from WMI

点点圈 提交于 2019-12-13 20:01:14
问题 tl;dr What should I SELECT instead of * in order to get the methods? More info: Here's an example: using (var s = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM someClass")) foreach (var obj in s.Get()) If I just ask for one property it's not enough - I get an exception when trying obj.InvokeMethod(...); . If I ask for * it is enough but I rather avoid this if possible. I don't see any property for getting the methods (- Disable , Enable ,...) in the docs for WMI classes. And if

Kill process by ParentProcessID

送分小仙女□ 提交于 2019-12-13 19:27:37
问题 I want to kill a running process by its ParentProcessID. I want to do it like you can do it in the commandline: wmic process where parentprocessid= 3008 terminate But now the thing is, in PowerShell I've the ParentProcessID as a variable like this: $p = 3008 And now I would like to kill the process by the varibale $p but this doesn't work: wmic process where parentprocessid= $p terminate How can I kill a process by its ParentProcessID, if I have the ParentProcessID stored in a variable? 回答1:

Execute a process in a remote machine using WMI

你离开我真会死。 提交于 2019-12-13 16:27:00
问题 I want to open process pon remote machine, this remote machine is inside local network. I try this command and in the remote machine nothing happen, this user that i connect with have administrators rights. Both machines running Windows 7 static void Main(string[] args) { try { //Assign the name of the process you want to kill on the remote machine string processName = "notepad.exe"; //Assign the user name and password of the account to ConnectionOptions object //which have administrative

Delete file on Remote Server Using WMI

自古美人都是妖i 提交于 2019-12-13 15:22:33
问题 I'm trying to delete an existing file on the remote server using WMI. Here's my code: string name = @"\\servername\\OCROut\\basketball.txt"; ConnectionOptions options = new ConnectionOptions(remoteServer, "username", "password", "ntlmdomain:domainName", ImpersonationLevel.Impersonate, AuthenticationLevel.Default, true, null, System.TimeSpan.MaxValue); ManagementScope scope = new ManagementScope("\\\\server\\root\\cimv2", options); scope.Connect(); var query = new ObjectQuery(string.Format(

Any faster method to get Volume Serial number?

橙三吉。 提交于 2019-12-13 14:42:56
问题 Hi I'm using this code to generate machine signature. But it's take noticeable time to execute. Wonder why it's that slow ? Any faster method recommended ? Public Shared Function DriveSN(ByVal DriveLetter As String) As String Dim disk As ManagementObject = New ManagementObject(String.Format("Win32_Logicaldisk='{0}'", DriveLetter)) Dim VolumeName As String = disk.Properties("VolumeName").Value.ToString() Dim SerialNumber As String = disk.Properties("VolumeSerialnumber").Value.ToString() Return

WMI lib to start windows service remotely

六月ゝ 毕业季﹏ 提交于 2019-12-13 11:08:55
问题 How do I start a service using the WMI library? The code below throws the exception: AttributeError: 'list' object has no attribute 'StopService' import wmi c = wmi.WMI ('servername',user='username',password='password') c.Win32_Service.StartService('WIn32_service') 回答1: There is documentation regarding the library on github: https://github.com/tjguk/wmi/blob/master/docs/cookbook.rst I believe the above code is throwing an error because you are not specifying which service to start. Assuming

How to convert a long datetime string to days in C#

时间秒杀一切 提交于 2019-12-13 10:27:10
问题 I need to be able to convert into days the long datetime string returned by the following wmi query: SelectQuery query = new SelectQuery("SELECT * FROM Win32_NetworkLoginProfile"); The propety name is PasswordAge. PasswordAge Data type: datetime Length of time a password has been in effect. This value is measured from the number of seconds elapsed since the password was last changed. Example: 00000011171549.000000:000 ManagementScope scope = CreateNewManagementScope(computerName); SelectQuery

How to get memory range used by a specific device with WMI (Windows Management Instrumentation)

别等时光非礼了梦想. 提交于 2019-12-13 07:23:01
问题 How can I get the resources used by a specific device (in particular, the memory range) of a specific device knowing it's name and/or DeviceID and/or the Pci bus number, Device number and function number? For example, I want to know what memory range an Intel AHCI Controller uses. With the query "SELECT * FROM Win32_IDEController WHERE Name LIKE\"%ahci%\"" I can get some info like the complete name, device id, and other informations. Then I thought that using the complete name or device id I

Print Job Accepting and routing Software

北城余情 提交于 2019-12-13 07:09:35
问题 I want to create a software which can accept Print Jobs from other computers, and then route those print jobs to PCs on LAN with printers attached. How it's going to happen -> 1- When that software called "Virtual Printer" is installed on a computer "X", Windows should think that it is a print driver/attached printer to that computer. 2- Then administrator of that PC goes to "Devices and Printers" in windows and select the "Virtual Printer", right click and view properties and select the

win32_USBDevice is missging from Win32 Classes

孤者浪人 提交于 2019-12-13 05:49:21
问题 I am trying to retrieve PID and VID of a connected USB device. Starting with this line of C# code: System.Management.ManagementClass USBClass = new ManagementClass("Win32_USBDevice"); Then I got exception "ManagementException not found" , Later I run into this link: http://msdn.microsoft.com/en-us/library/windows/desktop/aa394084(v=vs.85).aspx It turned out Win32_USBDevice was not on the list at all. Tried Win32_USBController but didn't get what I wanted. Could anyone let me know if there is