Jump to content

[Solved] @OSVersion autoit macro not correctly detecting windows 11 or windows server 2022 operating systems


Recommended Posts

Hey guys.  So, I have an autoit script that I wrote which is meant to activate windows on a fresh install of the operating system.  The code looks something like this:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Version=Beta
#AutoIt3Wrapper_UseX64=y
#AutoIt3Wrapper_Change2CUI=y
#AutoIt3Wrapper_Res_SaveSource=y
#AutoIt3Wrapper_Res_Language=1033
#AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator
#AutoIt3Wrapper_Add_Constants=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****


If @OSVersion = "WIN_10" Or @OSVersion = "WIN_2016" Then
    If @OSVersion = "WIN_10" Then
        Run ( @ComSpec & " /c " & 'slmgr.vbs -ipk <a key>' )
        $one = WinWait ( "Windows Script Host", "Installed product key <a key> successfully.", 5 )
        WinActivate ( $one )
        WinWaitActive ( $one, "", 5 )
        ControlClick ( $one, "", 2 )
    Else
        Run ( @ComSpec & " /c " & 'slmgr.vbs -ipk <a key>' )
        $one = WinWait ( "Windows Script Host", "Installed product key <a key> successfully.", 5 )
        WinActivate ( $one )
        WinWaitActive ( $one, "", 5 )
        ControlClick ( $one, "", 2 )
    EndIf

ElseIf @OSVersion = "WIN_11" Or @OSVersion = "WIN_2022" Then
    MsgBox ( 1, "Hello", "This is windows 11 or server 2022" )
    Run ( @ComSpec & " /c " & 'slmgr.vbs -ipk <os key>' )
        $one = WinWait ( "Windows Script Host", "Installed product key <os key> successfully.", 5 )
        WinActivate ( $one )
        WinWaitActive ( $one, "", 5 )
        ControlClick ( $one, "", 2 )

Else


EndIf
RunWait ( @ComSpec & " /c " & 'cscript //B "' & @SystemDir & '\slmgr.vbs" /ato' )

As you can see, for troubleshooting purposes, I included a messagebox in the event @OSVersion macro is Win_11 or Win_2022.  I just deployed windows 11 to one of my devices this evening and attempted to use the above script to activate my machine, and not only did the message box not appear, but my device was not activated.  This tells me that the @OSVersion macro does not correctly detect windows 11 or windows server 2022 machines (I also tested this on a windows server 2022 machine and ran into the same problem).  The macro does work for all of the other operating system versions.

Edited by MattHiggs
Link to comment
Share on other sites

@Danp2I will be damned.  When I went to re-compile the script, I noticed that autoit was compiling the script using the BETA version of autoit.  When I re-compiled the script using the production version of autoit, the script worked as intended.  Thanks for the input!!

XRoWyIV.png

a2O7iZm.png

 

Link to comment
Share on other sites

  • MattHiggs changed the title to [Solved] @OSVersion autoit macro not correctly detecting windows 11 or windows server 2022 operating systems

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...