wmi

VBScript: how to inspect validity of SWbemObjectSet?

倾然丶 夕夏残阳落幕 提交于 2019-12-23 15:28:25
问题 I have the following VBScript: SET Wmi = GetObject("winmgmts:\\.\root\cimv2") SET QR = Wmi.ExecQuery("SELECT * FROM Win32_Processor") MsgBox("" & QR.Count) Which works perfectly fine. However, when I query something which doesn't exist: SET Wmi = GetObject("winmgmts:\\.\root\cimv2") SET QR = Wmi.ExecQuery("SELECT * FROM Win32_DoesNotExist") MsgBox("" & QR.Count) I get the following error message: Script: E:\test.vbs Line: 3 Char: 1 Error: Invalid class Code: 80041010 Source: SWbemObjectSet

How to make forward-only, read-only WMI queries in C#?

谁说我不能喝 提交于 2019-12-23 15:13:17
问题 I've been told by a coworker that if my WMI system information gathering queries are forward-only and/or read-only, they'll be quite faster. That makes sense. But how do I do it? 回答1: You need to use EnumerationOptions class and set its Rewindable property to false. Here is an example: using System; using System.Management; namespace WmiTest { class Program { static void Main() { EnumerationOptions options = new EnumerationOptions(); options.Rewindable = false; options.ReturnImmediately =

VBScript to check for open process by user

不打扰是莪最后的温柔 提交于 2019-12-23 15:10:31
问题 I need a VBScript that will check if a process is in use by a specific user: Agent clicks program icon --> batch file calls for progcheck.vbs --> progcheck.vbs looks to see is "whatever.exe" is running under that user only --> if program is running under that user then MsgBox "Program running" --> wscript.quit (this needs to terminate out of the batch file) else --> return to batch file. I have tried this with tasklist in a batch file and the script works, but takes forever to run for a

ManagementEventWatcher for Win32_ProcessStartTrace no longer working in Win 8.1

℡╲_俬逩灬. 提交于 2019-12-23 10:21:20
问题 I have been using the ManagementEventWatcher in the past few months to watch for new processes starting, and it has worked without any issues. However, I just recently tried my app again, and it seems that the events for a new process are no longer getting called. Here is the sample code: var startWatch = new ManagementEventWatcher(new WqlEventQuery("SELECT * FROM Win32_ProcessStartTrace")); And the event: private static void ProcessStart_EventArrived(object sender, EventArrivedEventArgs e) {

Management Classes missing in Visual Studio Server Explorer

做~自己de王妃 提交于 2019-12-23 09:37:15
问题 I have an issue in Visual Studio 2015 (Professional 64-bit). In my Server Explorer, I connect to my local host and I can see Event Logs Message Queues Performance Counters Services What I seem to miss here, is Management Classes. On my previous PC (with VS2013), it was there. Did I forget to install an option (or extension)? Or is there an other easy way to generate classes for WMI interaction? Thanks! 回答1: On MS Connect (https://connect.microsoft.com/VisualStudio/feedback/details/2193804) it

WMI Linker Error on x64

隐身守侯 提交于 2019-12-23 09:32:15
问题 I'm trying to use the WMI example from msdn: http://msdn.microsoft.com/en-us/library/windows/desktop/aa384724%28v=vs.85%29.aspx I've copied the last set of code there verbatim into a console application in VS2008. If I have the application in release or debug for the win32 platform, it compiles (and runs) fine. If I have it in release or debug for the x64 platform, I get the following linker errors: CppConsole.obj : error LNK2001: unresolved external symbol IID_IWbemConfigureRefresher

PNPDeviceID Format

强颜欢笑 提交于 2019-12-23 09:29:13
问题 I'm working on developing a WMI query for my application. It needs to find the assigned virtual COM port for a given VID/PID. Using the WMI Code Creator I have found that... Namespace: root\CIMV2 Class: Win32_SerialPort Property: PNPDeviceID ...returns a value of USB\VID_10C4&PID_EA60\0001 . This same value can be found by going to the appropriate entry in Device Manager -> Properties -> Details tab and selecting Device Instance Id. My question is, what does the \0001 signify? Or, can I

C# WMI runs an exe on a remote PC that then runs another exe on the same PC that then calls Directory.CreateDirectory on a network path and fails

社会主义新天地 提交于 2019-12-23 09:08:50
问题 Using C# WMI I start an exe on another computer and this exe starts another exe using the C# Process class. The last exe tries to call Directory.CreateDirectory using a network path (aka \\\\comp1\d$\dir\ ). Directory.CreateDirectory throws this exception: Access to the path '\\\\blah\blah\blah' is denied. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.Directory.InternalCreateDirectory(String fullPath, String path, DirectorySecurity dirSecurity) at System

PowerShell script to get network card speed of a Windows Computer

≡放荡痞女 提交于 2019-12-23 08:37:11
问题 What is the PowerShell script to get the speed a specific Windows machine's network card is running at? I know this can be done with a WMI query based statement and will post an answer once I work it out. 回答1: A basic command is Get-WmiObject -ComputerName 'servername' -Class Win32_NetworkAdapter | ` Where-Object { $_.Speed -ne $null -and $_.MACAddress -ne $null } | ` Format-Table -Property SystemName,Name,NetConnectionID,Speed Note that the ComputerName parameter takes an array so you can

PowerShell script to get network card speed of a Windows Computer

梦想的初衷 提交于 2019-12-23 08:37:06
问题 What is the PowerShell script to get the speed a specific Windows machine's network card is running at? I know this can be done with a WMI query based statement and will post an answer once I work it out. 回答1: A basic command is Get-WmiObject -ComputerName 'servername' -Class Win32_NetworkAdapter | ` Where-Object { $_.Speed -ne $null -and $_.MACAddress -ne $null } | ` Format-Table -Property SystemName,Name,NetConnectionID,Speed Note that the ComputerName parameter takes an array so you can