- Notifications
You must be signed in to change notification settings - Fork0
Go wrapper around Device Console Windows tool.
License
mikerourke/go-devcon
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Go wrapper around theWindows Device Console (devcon.exe
).
go install github.com/mikerourke/go-devcon
Here's a brief overview of DevCon taken from the Windows Hardware Developer documentation site:
DevCon (Devcon.exe), the Device Console, is a command-line tool that displays detailed information about devices on computers running Windows.You can use DevCon to enable, disable, install, configure, and remove devices.
DevCon runs on Microsoft Windows 2000 and later versions of Windows.
This package provides a handy mechanism for querying devices and performing various operations on said devices.It provides methods that map directly to thedevcon.exe
commands.
You'll need thedevcon.exe
executable. It's not included in the package becauseRedistribution of Microsoft software without consent is usually a violation of Microsoft's End User License Agreements.
For information regarding how to get your hands ondevcon.exe
, check out theMicrosoft documentation page.
There areother ways to get it, but you didn't hear it from me.
There is extensive documentation and examples available on thedocs site, but here's a quick example of how to log all the devices on the computer:
package mainimport ("fmt""github.com/mikerourke/go-devcon")funcmain() {dc:=devcon.New(`\path\to\devcon.exe`)devs,err:=dc.FindAll("=net")iferr!=nil {panic(err) }for_,dev:=rangedevs {fmt.Printf("ID: %s, Name: %s\n",dev.ID,dev.Name) }}
Aren't you supposed to use thePnPUtil
now?
Yes, butPnPUtil
is only supported on Windows Vista and later. You can't use it on older operating systems.
Yes, but one of my other projects requires me to check for the existence of a device and install a driver on Windows XP.I wrote a bunch of parsing code to get the output, so I figured why not open source it?
Yes, I'm using only using Go APIs available in version1.10.7
(or earlier?), since executables built with that version of Go still run on Windows XP.It's possible that earlier versionsmay work, but I used1.10.7
during development, so I'd advise sticking with that version.To target Windows XP 32-bit, build your project like so:
GOOS=windows GOARCH=386 go1.10.7 build -o myproject.exe myproject.go
About
Go wrapper around Device Console Windows tool.