diff --git a/libmachine/mcnutils/os_windows.go b/libmachine/mcnutils/os_windows.go index 0a838fa9de..98a0106169 100644 --- a/libmachine/mcnutils/os_windows.go +++ b/libmachine/mcnutils/os_windows.go @@ -6,7 +6,7 @@ import ( ) func LocalOSVersion() string { - command := exec.Command(`systeminfo`) + command := exec.Command(`ver`) output, err := command.Output() if err != nil { return "" @@ -15,11 +15,5 @@ func LocalOSVersion() string { } func parseOutput(output string) string { - lines := strings.Split(string(output), "\n") - for _, line := range lines { - if strings.HasPrefix(line, "OS Version") { - return strings.TrimSpace(line[len("OS Version:"):]) - } - } - return "" + return strings.TrimSpace(output) } diff --git a/libmachine/mcnutils/os_windows_test.go b/libmachine/mcnutils/os_windows_test.go index 5134d289cb..4ae4bc14d2 100644 --- a/libmachine/mcnutils/os_windows_test.go +++ b/libmachine/mcnutils/os_windows_test.go @@ -8,13 +8,10 @@ import ( func TestOSWindows(t *testing.T) { output := ` -Host Name: DESKTOP-3A5PULA -OS Name: Microsoft Windows 10 Enterprise -OS Version: 10.0.10240 N/A Build 10240 -OS Manufacturer: Microsoft Corporation -OS Configuration: Standalone Workstation -OS Build Type: Multiprocessor Free -Registered Owner: Windows User + +Microsoft Windows [version 6.3.9600] + ` - assert.Equal(t, "10.0.10240 N/A Build 10240", parseOutput(output)) + + assert.Equal(t, "Microsoft Windows [version 6.3.9600]", parseOutput(output)) }