wmi

How to use WMI to add an IP route?

I need to add a route into the IP4 routing table on windows xp. However, the Win32_IP4RouteTable class seems to only be able to query existing routes. Basically I need the same functionality as: route ADD 192.168.127.254 MASK 255.255.255.255 192.168.1.10 Is it possible to use WMI to add an entry into the IP4 routing table? Could I ...

Get VPN IP address via WMI on Vista

How can we enumerate all the network connections in order to extract the IP address of the VPN connection using WMI? On XP, Win32_NetworkAdapterConfiguration works fine but on Vista it only seems to enumerate the physical connections... ...

How to call method with output parameters in Powershell?

I'm working on a script to get started in Powershell. I'm trying to convert a working VBScript script that enumerates mapped network drives on a remote Windows computer. One of the tasks is to use remote WMI to read the registry and find the process owner of explorer.exe in order to determine who is logged in. This seems easy enough g...

The user credentials supplied to the DirectoryEntry constructor are being ignored. What am I doing wrong

Hi. I have a really simple piece of code that creates a DirectoryEntry object which is attached to a w3svc object on a remote server. The C# code I have is as follows (NOTE: The code runs inside a windows WPF form) public static W3SvcWrapper CreateW3Svc(string machineName, string username...

How do I register as a real-time ETW consumer for NT Kernel Events?

I have been able to use logman with some success to dump some kernel traces. However, I'd like to be able to programatically enable real-time consumption of kernel events (mainly thread/process creation/deletion and file I/O) in my application. What is the best approach to this task? ...

Change DNS Zone from secondary to Primary with WMI ChangeZoneType

Hi, Has anyone used the WMI ChangeZoneType DNS command in C#\VB.net before. I get an incorrect parameter exception when i try and invoke the changezonetype command. I get the dns zone that i want to change from the dns server (via query), set the zonetype to the appropriate uint value but am then getting the exception. I am trying to ch...

Howto create an IIS Virtual Directory using a network share with WMI

I need to create a virtual directory within an IIS Site pointing at a network share \\servername\sharename\directory and I need to specify a specific user for the Pass-through authentication. I am after the WMI script to do this which I intend to call from a Powershell script. Although the target IIS environment is IIS7 (WMI namespace ...

Using PowerShell and WMI to read Security log

Hi, I'm building a script to read the Security Log from several computers. I can read the Security log from my local machine with no problem when using the Get-EventLog command, but the problem with it is that I can't run it against a remote machine (the script is for powershell v1). The command below never returns any results, although ...

Does the WMI event Win32_VolumeChangeEvent work on Windows XP

I'm trying to use the following c# code to detect the attached/removed event of usb mass storage devices. I'm using the Win32_VolumeChangeEvent. // Initialize an event watcher and subscribe to events that match this query var _watcher = new ManagementEventWatcher("select * from Win32_VolumeChangeEvent"); _watcher.EventArr...

why does wmi process win32_xxx queries faster than cim_xxx queries?

PS D:\work\scripts> measure-command { get-wmiobject -query "select * from win32_service" | Where-Object -FilterScript {$ _.Name -eq "WinRM"} } Days : 0 Hours : 0 Minutes : 0 Seconds : 0 Milliseconds : 426 Ticks : 4262955 TotalDays : 4.93397569444444E-06 TotalHours ...

Good resources to learn WMI in .NET?

I'm looking for recommendations for good resources are there out there to learn WMI. Interested in all types; books, online, webcasts, etc. ...

VB using WMI - get logged in users

How can I use VB scripting with WMI to get the # of logged in users. My installation can only have one user logged in and needs to report an error if more than one user is logged in (via terminal service using Citrix). I don't know that much about Citrix but the Win32_LogonSession with LogonType = 10 seems to return all kinds of junk (po...

How to program hardware performance counters

I've been dealing with this problem for my thesis. The goal is to develop a .net server monitoring tool specifically for windows 2K8 servers. So far, all I can access are software performance counters. Meaning those that are available through perfmon and the WMI classes. But then there's also the issue that I need to be able to monitor ...

Is there something like WMI for Linux?

I like the whole WMI concept, and I could really make use of it under Linux ( in some scripts ). Is there something like that for Linux systems? ...

Programatically removing etag suffix (change number) from the metabase IIS6

IIS 6.0 generates eTag values in the format of "hash:changenumber". The changenumber goes up every time IIS resets, so your eTag is only valid for the lifetime of your IIS process. Restart, number goes up, hash:changenumber != hash:changenumber+1. The fix for this is to hard-code the changenumber, which is possible using the Metabase E...

How to start script(vbs) with WMI in C# code?

I need to start a Visual Basic script file by using WMI in a c# code. I don't quite understand what is wrong with this piece of code? Result will be always 8 (Unknown failure). But for example notepad.exe can be started without failure. //Get the object on which the method will be invoked ManagementClass processClass = ...

WMI query on CMI_DataFile class yields "Invalid query" if it has "where condition1 AND condition2" (C#)

OK, here's what I'm doing distilled to only the System.Management calls: Simple queries and Method invokes work over the same connection. This query won't. And the file exists on the remote machine. Clues? myQuery = "Select * from CIM_DataFile Where Drive = 'C:' AND Path = '\\Users\\someguy\\Documents\\' AND FileName = 'Default' AND Ex...

Use WMI to create DNS entries

Is it possible to create DNS entries using WMI (Windows Management Instrumentation)? Thank you ...

Anyone has sample code that makes WMI queries to the CIM_DataFile class?

Something that does SELECT's to get info about a file or directory? Something that actually works? Language doesn't matter, I'm most interested in the query syntax. ...

Enumerate files with case sensitivity in VBScript?

I am using the following VBScript code snippet to enumerate all files in my c:\Scripts\ folder: strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colFiles = objWMIService. _ ExecQuery("Select * from CIM_DataFile where Path = '\\Scripts\\'") Fo...