VIP

Determining Windows Version? @OSVersion Returns

18 posts in this topic

Autoit 3.3.12.19

Windows Technical Preview (Win9)
@OSVersion
Returns WIN_NT

Windows 10 
Technical Preview
@OSVersion
Returns WIN_NT4




 


Regards,
 

Share this post


Link to post
Share on other sites



What function AutoIT used to determine OSVersion?
GetVersion() or GetVersionEx() function in the kernel32.dll ?


Regards,
 

Share this post


Link to post
Share on other sites

FileGetVersion(@SystemDir & "Winver.exe") is the only one that is working! The second Registry Key by Deathbringer is working on XP above but in compatibility mode it shows the OS that it is being run in. Also, anything that retrieves the version from Kernel32.dll >> GetVersionEx is affected. I learnt something today! :x


Regards,
 

Share this post


Link to post
Share on other sites

I think GetVersionEx is no deprecated


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

It makes sense though that the Windows tools that indicate the version are modified by compatibility mode, right? To "fool" applications that base checks on the windows version...

But indeed:

https://msdn.microsoft.com/en-us/library/windows/desktop/ms724451%28v=vs.85%29.aspx:

[GetVersionEx may be altered or unavailable for releases after Windows 8.1. Instead, use the Version Helper APIs]

... on to the version helper apis: https://msdn.microsoft.com/en-us/library/windows/desktop/dn424972(v=vs.85).aspx

Nice suite of functions. Doesn't seem to support Windows 9 tech preview, but maybe you can use the "goalkeeper-function" IsWindowsVersionOrGreater:
 

BOOL WINAPI IsWindowsVersionOrGreater(
  WORD wMajorVersion,
  WORD wMinorVersion,
  WORD wServicePackMajor
);
1 person likes this

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

I thought Windows 9 moved to Windows 10? As it supports the tech preview called Windows 10.

I doubt Microsoft are going to support a tech preview which I outdated.

Edited by guinness
1 person likes this

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

I agree, I thought so too. I wouldn't expect a function supporting a discarded version name that no one should be running. But who knows... If it exists it exists, and maybe the IsWindowsVersionOrGreater will tell you about it :)


Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites

I have found the following registry keys reliable:

  • HKLMSOFTWAREMicrosoftWindows NTCurrentVersionProductName
  • HKLMSOFTWAREMicrosoftWindows NTCurrentVersionCurrentVersion

TX Techie

Share this post


Link to post
Share on other sites

easy to fake


Regards,
 

Share this post


Link to post
Share on other sites

Was Windows 9 ever released officially? I don't recall ever seeing it, I heard rumors about it before they renamed it to 10, but I don't know that it was an official release of a beta was it? If Microsoft never released a version called Windows 9, I wouldn't expect any software to be obligated to detecting it.

Also, if you're using Windows 9 (official or not) you should update it to the latest technical preview of 10, because after all, it's a beta that is probably buggy as hell.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

What function AutoIT used to determine OSVersion?

GetVersion() or GetVersionEx() function in the kernel32.dll ?

as always need to use the search field in the forum

will have to be

Local $OSVERSIONINFOEX = DllStructCreate("dword OSVersionInfoSize;dword MajorVersion;dword MinorVersion;dword BuildNumber;dword PlatformId;char CSDVersion[128];word ServicePackMajor;word ServicePackMinor;ushort SuiteMask;BYTE ProductType")
    DllStructSetData($OSVERSIONINFOEX, "OSVersionInfoSize", DllStructGetSize($OSVERSIONINFOEX))
    Local $retVal = DllCall("Ntdll.dll", "INT", "GetVersion", "ptr", DllStructGetPtr($OSVERSIONINFOEX))
    If @Error Then
        $OSVERSIONINFOEX = FileGetVersion(@SystemDir & "\ntoskrnl.exe")
        If @Error Then $OSVERSIONINFOEX = FileGetVersion(@SystemDir & "\winver.exe")
        If @Error Then $OSVERSIONINFOEX = RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "CurrentVersion")
        $OSMajorVersion = StringLeft($OSVERSIONINFOEX, 1)
        $OSMinorVersion = StringMid($OSVERSIONINFOEX, 3, 1)
        $OSCurrentVersion = $OSMajorVersion & "." & $OSMinorVersion
        $OSServicePackMajor = StringRight(@OSServicePack, 1)
        $OSServicePackMinor = 0
        $OSBuildNumber = @OSBuild
        $OSCSDVersion = @OSServicePack
        $OSArchitecture = @OSArch
        $OSLanguage = @MUILang
        $OSUserName = @UserName
        $OSSystemDrive = @HomeDrive
        $OSVersionNumber = $OSCurrentVersion & "." & $OSBuildNumber
    Else
        $OSMajorVersion = String(DllStructGetData($OSVERSIONINFOEX, "MajorVersion"))
        $OSMinorVersion = String(DllStructGetData($OSVERSIONINFOEX, "MinorVersion"))
        $OSServicePackMajor = String(DllStructGetData($OSVERSIONINFOEX, "ServicePackMajor"))
        $OSServicePackMinor = String(DllStructGetData($OSVERSIONINFOEX, "ServicePackMinor"))
        $OSBuildNumber = String(DllStructGetData($OSVERSIONINFOEX, "BuildNumber"))
        $OSCSDVersion = String(DllStructGetData($OSVERSIONINFOEX, "CSDVersion"))
        ;;$OSPlatformId = String(DllStructGetData($OSVERSIONINFOEX, "PlatformId"))
        ;;$OSSuiteMask = String(DllStructGetData($OSVERSIONINFOEX, "SuiteMask"))
        ;;$OSProductType = String(DllStructGetData($OSVERSIONINFOEX, "ProductType"))
        $OSCurrentVersion = $OSMajorVersion & "." & $OSMinorVersion
        $OSArchitecture = @OSArch
        $OSLanguage = @MUILang
        $OSUserName = @UserName
        $OSSystemDrive = @HomeDrive
        $OSVersionNumber = $OSCurrentVersion & "." & $OSBuildNumber
    EndIf

Windows 9 has never existed exactly for this reason, there is confusion (problems) between WinNT9 and WinNT95 (at least so said microsoft officially)

Ciao.

Edited by DXRW4E
1 person likes this

OneDrive_Logo.png drive_app_badge.png box-logo.png new_logo.png MEGA_Logo.png

Share this post


Link to post
Share on other sites

Autoit 3.3.12.19

Windows Technical Preview (Win9)

@OSVersion

Returns WIN_NT

Windows 10 Technical Preview

@OSVersion

Returns WIN_NT4

 

see if this fits your needs.

Func OsVersion()
    If FileExists(@WindowsDir & '\winver.exe') Then
        Return FileGetVersion(@WindowsDir & '\winver.exe')
    ElseIf FileExists(@WindowsDir & '\System\winver.exe') Then
        Return FileGetVersion(@WindowsDir & '\System\winver.exe')
    ElseIf FileExists(@WindowsDir & '\System32\winver.exe') Then
        Return FileGetVersion(@WindowsDir & '\System32\winver.exe')
    ElseIf FileExists(@WindowsDir & '\SysWOW64\winver.exe') Then
        Return FileGetVersion(@WindowsDir & '\SysWOW64\winver.exe')
    Else
        Return "0.0.0.0"
    EndIf
EndFunc   ;==>OsVersion
1 person likes this

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

see if this fits your needs.

Func OsVersion()
    If FileExists(@WindowsDir & '\winver.exe') Then
        Return FileGetVersion(@WindowsDir & '\winver.exe')
    ElseIf FileExists(@WindowsDir & '\System\winver.exe') Then
        Return FileGetVersion(@WindowsDir & '\System\winver.exe')
    ElseIf FileExists(@WindowsDir & '\System32\winver.exe') Then
        Return FileGetVersion(@WindowsDir & '\System32\winver.exe')
    ElseIf FileExists(@WindowsDir & '\SysWOW64\winver.exe') Then
        Return FileGetVersion(@WindowsDir & '\SysWOW64\winver.exe')
    Else
        Return "0.0.0.0"
    EndIf
EndFunc   ;==>OsVersion

#include <MsgBoxConstants.au3>
#include <WinAPI.au3>

MsgBox($MB_SYSTEMMODAL, "", _WinAPI_PathFindOnPath("winver.exe"))
A better way of finding winver.exe without hardcoding all possible paths. Edited by guinness
1 person likes this

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

Good point JohnOne.


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now