What is the best way to get windows full name from go? -


in windows, can run systeminfo | findstr /c:"os name output windows full name console. i've tried couple different variations of piping output 1 command other, empty strings.

example

first := exec.command("systeminfo") second := exec.command("findstr /c:'os name'")  reader, writer := io.pipe()  first.stdout = writer second.stdin = reader  var buffer bytes.buffer second.stdout = &buffer  first.start() second.start() first.wait() writer.close() second.wait()  output := buffer.string()  log.printf("output: %s", output) 

`

are there built in methods information?

one way use golang.org/x/sys/windows/registry package.

a simple example:

package main  import (     "fmt"     "golang.org/x/sys/windows/registry" )  func main() {     key, _ := registry.openkey(registry.local_machine, `software\microsoft\windows nt\currentversion`, registry.query_value) // error discarded brevity     defer key.close()     productname, _, _ := key.getstringvalue("productname") // error discarded brevity     fmt.println(productname) } 

this prints windows 8.1 pro on computer.


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -