Skip to content

esp0/WmiLight

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WmiLight wmilight MyGet Build Status

What is WmiLight?

A simple and light wmi framework. It has only one function: sending WMI queries. It's a subset of the System.Management.Instrumentation namespace.

In which case should you use WmiLight?

The .Net framework implementation has one big problem. It leaks a little bit memory on each remote operation. Use this framework if your application is a service or runes a long time and you're sending a lot of remote queries.

Installation

This project is being distributed as a sNuGet package, so open your Package Manager Console window and execute the following command.

NuGet

How to use?

Query all running processes for the local machine:

using (WmiConnection conncetion = new WmiConnection())
{
    foreach (WmiObject process in conncetion.CreateQuery("SELECT * FROM Win32_Process"))
    {
        Console.WriteLine(process["Name"]);
    }
}

Query all partitions for a remote machine:

var opt = new WmiConnectionOptions() { EnablePackageEncryption = true };
var cred = new NetworkCredential("USERNAME", "PASSWORD", "DOMAIN");

using (WmiConnection conncetion = new WmiConnection(@"\\MACHINENAME\root\cimv2", cred, opt))
{
    foreach (WmiObject partition in conncetion.CreateQuery("SELECT * FROM Win32_DiskPartition"))
    {
        Console.WriteLine(partition["Name"]);
    }
}

Other benefits:

  • easy usage

  • no distinction between local and remote queries

  • Debugger Preview

    Debugger_Preview

About

A simple and light wmi framework.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 100.0%