wmi

C# detect usb device ClassCode (usb device type)

岁酱吖の 提交于 2019-12-18 05:47:45
问题 I need to know what kind of USB devices currently used in system. There is a USB specification about class codes of USB devices. But I cant get device type, WMI request WQL: select * from Win32_UsbHub give null values on Class code, Subclass code, Protocol type fields. Any ideas how to detect USB device type currently in use? My current code: ManagementObjectCollection collection; using (var searcher = new ManagementObjectSearcher(@"Select * From Win32_USBHub")) { collection = searcher.Get();

Is there a way to generate WMI code/classes?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-18 04:17:11
问题 How do you generate C# classes for accessing WMI? 回答1: To generate strongly typed WMI classes, use the Management Strongly typed class generator (MgmtClassGen.exe). It's usually in C:\Program Files\Microsoft Visual Studio X\SDK\vX\Bin. The parameters are at MSDN and they even have a page describing the code generated. If you have to do a lot of work with WMI, it's a lifesaver. 回答2: Easier approach (Visual Studio users): Add WMI classes to VisualStudio's Server Explorer. E.g. Get Visual Studio

How to read ManagementObject Collection in WMI using C#

与世无争的帅哥 提交于 2019-12-17 23:17:59
问题 I found a code on net and have been trying to get more information about mo[] . I am trying to get all the information contained in ManagementObjectCollection. Since parameter in mo is looking for an string value which I dont know, how can I get all the values without knowing its parameter values. Or if I want to get all the indexer values related to mo in ManagementObjectCollection ManagementObjectSearcher objOSDetails = new ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem");

How can I get an active UNC Path in DFS programatically

不想你离开。 提交于 2019-12-17 19:17:14
问题 Given a DFS path how would I know what is the active path it is currently on programatically. For exmaple I have 2 Servers shares as "\\Server1\Folder\" and "\\Server2\Folder\" and it has DFS turned on so it can be accessed on "\\DFS_Server\Folder\" , how would I know what is the active path currently "\\DFS_Server\Folder\" is on, whether it is "\\Server1\Folder\" or "\\Server2\Folder\" . 回答1: try this where sDFSPath is the path you want to query and sHostServer is the Server you want to

Getting Service Tag from Dell Machine using .net?

余生长醉 提交于 2019-12-17 17:58:37
问题 I've got a class that pulls model information (hardware info) for a local machine code is like so: Imports System.Management Public Class clsWMI Private objOS As ManagementObjectSearcher Private objCS As ManagementObjectSearcher Private objMgmt As ManagementObject Private m_strComputerName As String Private m_strManufacturer As String Private m_StrModel As String Private m_strOSName As String Private m_strOSVersion As String Private m_strSystemType As String Private m_strTPM As String Private

Monitor Drive. Using VB Script

僤鯓⒐⒋嵵緔 提交于 2019-12-17 14:55:39
问题 I want to monitor a drive for file changes, using VBScript. I have the below code. It works fine for InstanceCreationEvent and InstanceDeletionEvent . But InstanceModificationEvent is not happening. From googling I got to know we need to use CIM_DataFile instead of CIM_DirectoryContainsFile to monitor InstanceModificationEvent . I am not sure how to modify the code. Can anyone help. FYI: One script should monitor all the folders and subfolders in a drive. PS: Any suggestion to improve the

How to Read Remote Registry Keys?

荒凉一梦 提交于 2019-12-17 09:42:23
问题 I need to be able to read the values in a specific Registry Key from a list of Remote Computers. I can do this locally with the following code using Microsoft.Win32; RegistryKey rkey = Registry.LocalMachine; RegistryKey rkeySoftware=rkey.OpenSubKey("Software"); RegistryKey rkeyVendor = rkeySoftware.OpenSubKey("VendorName"); RegistryKey rkeyVersions = rkeyVendor.OpenSubKey("Versions"); String[] ValueNames = rkeyVersions.GetValueNames(); foreach (string name in ValueNames) { MessageBox.Show

Trying to copy file from one XP PC to another using WMI, since RPC and UNC are not available

吃可爱长大的小学妹 提交于 2019-12-17 04:07:18
问题 I'm new to VBScript. I cannot find a way to copy files from one XP host to another using WMI in a VBS. The usual way of copying files (RPC - Remote Procedure Call, SMB, UNC) are not available to several hosts but WMI is available to all hosts, and I need to copy files from my admin host to a target Windows host. I thought I'd find some sample code out there but I've found no info on it. Haven't found anything telling me it can't be done, either. The source files are an executable and 'test1

How can I find the Upgrade Code for an installed MSI file?

↘锁芯ラ 提交于 2019-12-17 02:24:17
问题 In certain cases the need to retrieve MSI upgrade codes for deployed packages can arise. Common scenarios: I took over someone else's MSI project, and I need to determine what upgrade codes were used for previous versions that are already in the wild. This is necessary to handle upgrade scenarios. I have no archive of releases anywhere . I accidentally changed the upgrade code for my WiX package several times during development and I need to find all Upgrade Code versions "in the wild". I was

Detecting USB drive insertion and removal using windows service and c#

会有一股神秘感。 提交于 2019-12-16 22:37:14
问题 Looking into possibility of making an USB distributed application that will autostart on insertion of an USB stick and shutdown when removing the stick Will use .Net and C#. Looking for suggestion how to approach this using C#? Update: Two possible solutions implementing this as a service. - override WndProc or - using WMI query with ManagementEventWatcher 回答1: You can use WMI, it is easy and it works a lot better than WndProc solution with services. Here is a simple example: using System