Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] winver.exe output as platform version for windows hosts #1503

Closed
jxsl13 opened this issue Aug 11, 2023 · 3 comments
Closed

[RFC] winver.exe output as platform version for windows hosts #1503

jxsl13 opened this issue Aug 11, 2023 · 3 comments
Labels

Comments

@jxsl13
Copy link

jxsl13 commented Aug 11, 2023

Is your feature request related to a problem? Please describe.

Both strings: kernel version and platform version contain the exact same string.

It might make sense to change the platform version to the string that is output by winver.exe

which looks like this:
Version 22H2 (Build 22621.1992)

Reference implementation: https://github.com/jxsl13/osfacts/blob/master/distro/distro_windows.go#L51

image

package main

import (
	"encoding/json"
	"fmt"
	"log"

	"github.com/shirou/gopsutil/v3/host"
)

func main() {
	info, err := host.Info()
	if err != nil {
		log.Fatalln(err)
	}

	data, _ := json.MarshalIndent(info, "", " ")
	fmt.Println(string(data))
}

Output

{
 "hostname": "windows-laptop",
 "uptime": 18048,
 "bootTime": 1691735912,
 "procs": 305,
 "os": "windows",
 "platform": "Microsoft Windows 11 Enterprise",
 "platformFamily": "Standalone Workstation",
 "platformVersion": "10.0.22621.1992 Build 22621.1992",
 "kernelVersion": "10.0.22621.1992 Build 22621.1992",
 "kernelArch": "x86_64",
 "virtualizationSystem": "",
 "virtualizationRole": "",
 "hostId": "12ba0ae0-383e-11ee-84a6-bbe395fdc6b9"
}
@shirou
Copy link
Owner

shirou commented Aug 16, 2023

According to this page, it seems that BuildNumber is the version of the development build, and Version such as 22H2 is used as the release. Therefore, it would be correct to use Version.

However, if I remember correctly, this version information cannot be obtained from WMI or other sources. Therefore, we use BuildNumber.

Also, even if we could get the Version, it does not seem appropriate to change this value now. It seems to me that you would need to raise a major version.

@jxsl13
Copy link
Author

jxsl13 commented Aug 16, 2023

Do you mean that 22H2 cannot be obtained or what exactly cannot be obtained as "Version"?

I have linked a reference implementation in my first post which obtains 22H2 from the registry.

Tho I don't know much of Windows internals to evaluate if the solution works for all cases as intended (especially requiring some special permissions to read the registry), but at least it did work on my Windows machine.

@shirou
Copy link
Owner

shirou commented Aug 17, 2023

Ah, I see that DisplayVersion was added. In Windows 10 there was a ReleaseId, but it was replaced in the process, and I think there was some problem in the case of Windows 7 as well (but I can not remember...).

However, since Windows 7 is no longer supported by golang from golang 1.21, it may be a good idea to change platformVersion to return DisplayVersion such as 22H2.

But as I said, this changes may break some compatibility. So I also want to request comments about this change.

Possible options:

  1. We can make this change now.
  2. We can make this change after golang 1.20 deprecated which drops Windows 7 support.
  3. We can make this change but with new major version.
  4. No, we can not change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants