Page 1 of 1
A_OSVersion for Win10/11
Posted: 05 Dec 2023, 10:39
by just me
The version number of the operating system, in the format "major.minor.build". For example, Windows 7 SP1 is 6.1.7601.
For Win 10 and 11 "major.minor" is
10.0 for all existing versions. Only the "build" numbers differ. The following
Map associates the build numbers with Microsoft's version names:
Code: Select all
Win_10_11_Builds := Map(10240, "Win 10 1507",
10586, "Win 10 1511",
14393, "Win 10 1607",
15063, "Win 10 1703",
16299, "Win 10 1709",
17134, "Win 10 1803",
17763, "Win 10 1809",
18362, "Win 10 1903",
18363, "Win 10 1909",
19041, "Win 10 2004",
19042, "Win 10 20H2",
19043, "Win 10 21H1",
19044, "Win 10 21H2",
19045, "Win 10 22H2",
22000, "Win 11 21H2",
22621, "Win 11 22H2",
22631, "Win 11 23H2")
To be continued!
Re: A_OSVersion for Win10/11
Posted: 13 Mar 2024, 12:01
by novelprocedure
For anyone who stumbles across this post, here is a simple function to determine if you're running Windows 10 or Windows 11.
Code: Select all
GetWinOSVersion()
{
i := A_OSVersion
If (i < 10.0.20000) ; You're running Windows 10
Return 10
Else If (i >= 10.0.20000) ; You're running Windows 11
Return 11
}
Re: A_OSVersion for Win10/11
Posted: 13 Mar 2024, 12:13
by gregster
novelprocedure wrote: ↑13 Mar 2024, 12:01
For anyone who stumbles across this post, here is a simple function to determine if you're running Windows 10 or Windows 11.
I doubt that this will work correctly. Afaik, you can't use operators like
< and
>= like this on undefined constructs like 10.0.20000.
Try
i := 9, it will still output
11, because
10.0.20000 will evaluate to
blank in AHK v1 (try
msgbox % 10.0.20000), and in AHK v2 this code won't run at all.
Try
StrSplit() to get the final part of the OS version string and then compare the resulting numbers.
Re: A_OSVersion for Win10/11
Posted: 13 Mar 2024, 22:20
by Marium0505
Here are two functions, the first one works from
v1.1.36.00+ (including v2):
Code: Select all
; From v1.1.36.00+ (including v2)
GetWinOSVersion(WindowsVersion := "") {
Ver := 0
static Versions := [[">=10.0.20000", "11"], [">=10.0.10000", "10"], [">=6.3", "8.1"], [">=6.2", "8"], [">=6.1", "7"], [">=6.0", "Vista"], [">=5.2", "XP"], [">=5.1", "XP"]]
If !(WindowsVersion)
WindowsVersion := A_OSVersion
If (WindowsVersion = "WIN_7")
Ver := "7"
Else If (WindowsVersion = "WIN_8.1")
Ver := "8.1"
Else If (WindowsVersion = "WIN_VISTA")
Ver := "Vista"
Else If (WindowsVersion = "WIN_XP")
Ver := "XP"
Else {
static Versions := [[">=10.0.20000", "11"], [">=10.0.10000", "10"], [">=6.3", "8.1"], [">=6.2", "8"], [">=6.1", "7"], [">=6.0", "Vista"], [">=5.2", "XP"], [">=5.1", "XP"]]
for i, Version in Versions {
If !(VerCompare(WindowsVersion, Version[1]))
continue
Ver := Version[2]
break
}
}
return Ver
}
Both returns 0 if less than XP, otherwise it returns 11,10,8.1,8,7,Vista, or XP as a string.
Re: A_OSVersion for Win10/11
Posted: 29 Mar 2024, 16:17
by RaptorX
novelprocedure wrote: ↑13 Mar 2024, 12:01
For anyone who stumbles across this post, here is a simple function to determine if you're running Windows 10 or Windows 11.
Code: Select all
GetWinOSVersion()
{
i := A_OSVersion
If (i < 10.0.20000) ; You're running Windows 10
Return 10
Else If (i >= 10.0.20000) ; You're running Windows 11
Return 11
}
I think you would have to use
VerCompare for this type of comparison.
What you just tried would break because those are not actual numbers due to the second
. in the versioning system.
Re: A_OSVersion for Win10/11
Posted: 17 Apr 2024, 09:01
by xMaxrayx
just me wrote: ↑05 Dec 2023, 10:39
The version number of the operating system, in the format "major.minor.build". For example, Windows 7 SP1 is 6.1.7601.
For Win 10 and 11 "major.minor" is
10.0 for all existing versions. Only the "build" numbers differ. The following
Map associates the build numbers with Microsoft's version names:
Code: Select all
Win_10_11_Builds := Map(10240, "Win 10 1507",
10586, "Win 10 1511",
14393, "Win 10 1607",
15063, "Win 10 1703",
16299, "Win 10 1709",
17134, "Win 10 1803",
17763, "Win 10 1809",
18362, "Win 10 1903",
18363, "Win 10 1909",
19041, "Win 10 2004",
19042, "Win 10 20H2",
19043, "Win 10 21H1",
19044, "Win 10 21H2",
19045, "Win 10 22H2",
22000, "Win 11 21H2",
22621, "Win 11 22H2",
22631, "Win 11 23H2")
To be continued!
novelprocedure wrote: ↑13 Mar 2024, 12:01
For anyone who stumbles across this post, here is a simple function to determine if you're running Windows 10 or Windows 11.
Code: Select all
GetWinOSVersion()
{
i := A_OSVersion
If (i < 10.0.20000) ; You're running Windows 10
Return 10
Else If (i >= 10.0.20000) ; You're running Windows 11
Return 11
}
Hi, the issue with this mothed is you relay in your database, if new Windows like WIN12 exit this mothed need to re-fix again.
Re: A_OSVersion for Win10/11
Posted: 17 Apr 2024, 09:09
by xMaxrayx
here is a mothed that dosn't relay on devs Database sadly it doesn't use AHK, also you may need another way to hide you CMD pop-out
Code: Select all
#Requires AutoHotkey v2.0
MsgBox(ComObject("WScript.Shell").Exec('cmd.exe /c systeminfo | findstr /b /c:"OS Name"').StdOut.ReadAll())
beside there is another issue is relay if windows have
systeminfo exited.