Giter VIP home page Giter VIP logo

wmi's Introduction

wmi

Go Reference

Package wmi provides an interface to WMI. (Windows Management Instrumentation)

Install

go get -v github.com/moonchant12/wmi

Import

import "github.com/moonchant12/wmi"

Usage

Call method with params

// Create process using WMI
func main() {
	// https://docs.microsoft.com/en-us/windows/win32/cimwin32prov/win32-process
	// https://docs.microsoft.com/en-us/windows/win32/cimwin32prov/create-method-in-class-win32-process
	// https://docs.microsoft.com/en-us/windows/win32/cimwin32prov/win32-processstartup
	wmi.With("Win32_ProcessStartup", func(objStartupConfig *ole.IDispatch) error {
		var pid int32
		objStartupConfig.PutProperty("CreateFlags", windows.CREATE_NEW_CONSOLE)
		objStartupConfig.PutProperty("Title", "nice")
		log.Println(wmi.CallMethod("Win32_Process", "Create", "cmd /C notepad.exe", "C:\\Windows\\System32", objStartupConfig, &pid))
		log.Println(pid)
		return nil
	})
}

Outcome

2022/01/03 00:00:00 0 <nil>
2022/01/03 00:00:00 9996

Query

// Query system processes information using WMI
func main() {
	var res []struct {
		Name        string
		HandleCount uint32
	}
	wmi.Query("SELECT Name, HandleCount FROM Win32_Process", &res)
	log.Println(res)
}

Outcome

2022/01/03 00:00:00 [{System Idle Process 0} {System 3860} {Secure System 0} {Registry 0}
...

wmi's People

Contributors

moonchant12 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.