Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/bi-zone/wmi

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/bi-zone/wmi

  • v1.1.4
  • Source
  • Go
  • Socket score

Version published
Created
Source

wmi

GoDoc Go Report Card

Package wmi provides a WMI Query Language (WQL) interface for Windows Management Instrumentation (WMI) on Windows.

This package uses COM API for WMI therefore it's only usable on the Windows machines.

Package reference is available at https://godoc.org/github.com/bi-zone/wmi

Fork Features

Fork is fully compatibly with the original repo. If not - please open an issue.

New features introduced in fork:

  • Go 1.11 modules support :)
  • Improved decoder:
    • support all basic types: all integer types, float32, string, bool, uintptr and time.Time
    • support slices and pointers to all basic types
    • support decoding of structure fields (see events example)
    • support structure tags
    • support JSON-like interface for custom decoding
    • suitable for decoding properties of any go-ole IDispatch object
  • Ability to perform multiple queries in a single connection
  • SWbemServices.Get + auto dereference of REF fields
  • SWbemServices.ExecNotificationQuery support
  • More other improvements described in releases page

Example

Print names of the currently running processes

package main

import (
   "fmt"
   "log"

   "github.com/bi-zone/wmi"
)

type win32Process struct {
   PID       uint32 `wmi:"ProcessId"`
   Name      string
   UserField int `wmi:"-"`
}

func main() {
   var dst []win32Process

   q := wmi.CreateQueryFrom(&dst, "Win32_Process", "")
   fmt.Println(q)

   if err := wmi.Query(q, &dst); err != nil {
   	log.Fatal(err)
   }
   for _, v := range dst {
   	fmt.Printf("%6d\t%s\n", v.PID, v.Name)
   }
}

A more sophisticated examples are located at in examples folder.

Benchmarks

Using DefaultClient, SWbemServices or SWbemServicesConnection differ in a number of setup calls doing to perform each query (from the most to the least).

Estimated overhead is shown below:

BenchmarkQuery_DefaultClient   5000  33529798 ns/op
BenchmarkQuery_SWbemServices   5000  32031199 ns/op
BenchmarkQuery_SWbemConnection 5000  30099403 ns/op

You could reproduce the results on your machine running:

go test -run=NONE -bench=Query -benchtime=120s

Versioning

Project uses semantic versioning for version numbers, which is similar to the version contract of the Go language. Which means that the major version will always maintain backwards compatibility with minor versions. Minor versions will only add new additions and changes. Fixes will always be in patch.

This contract should allow you to upgrade to new minor and patch versions without breakage or modifications to your existing code. Leave a ticket, if there is breakage, so that it could be fixed.

FAQs

Package last updated on 06 Aug 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc