romulocarlos Posted October 3, 2016 Posted October 3, 2016 Hello. I'm building a script to install some windows updates with a GUI. For this, the script need to know witch windows version to work: Windows 7, Windows 7 SP1, Windows 8, Windows 8.1 and so on. I read this article, but it don't list Windows 10 Anniversary Edition. So, I run into build version, because they are different between them. The first is 10586, and Anniversary is 14393. So, somewhere on my script I have this: If @OSVersion = 'win_10' Then $versao_windows = 'Windows 10' ElseIf @OSVersion = 'win_10' And @OSBuild = 14393 Then $versao_windows = 'Windows 10 Edição De Aniversário' $win10ae = 1 EndIf As you see, "$versao_windows" is the "friendly" name to be showed on the GUI, and "$win10ae" will be the variable to be used to distinguish the windows version to use. But the script still showing the 'normal' Windows 10 version, even if it is running on Anniversary Edition. On the status bar, it rightly shows the 14393 build, but don't shows "Windows 10 Edição De Aniversário". I need this to install the correct updates, because they are different from one build to another. Where I'm wrong on my code? Thanks in advice!
AutoBert Posted October 3, 2016 Posted October 3, 2016 9 minutes ago, romulocarlos said: Where I'm wrong on my code? May at a other place, the snipet ic correct. Make a runable (reproducer) script, showing your issue(s).
spudw2k Posted October 3, 2016 Posted October 3, 2016 (edited) I think your approach with if statement (as it stands) isn't using the best logic. I suspect since the first condition is true, the rest does not process. This is how I would do it: check the windows version first, then evaluate subversion. ;crude example If @OSVersion = "WIN_10" Then $versao_windows = 'Windows 10' If @OSBuild = 14393 Then $versao_windows &= " Edição De Aniversário" $win10ae = 1 EndIf EndIf edit: just a demo further demonstrate why your logic doesn't work: $iValueA = 1 $iValueB = 1 If $iValueA = 1 Then $sTest = "$iValue = 1" ElseIf $iValueA = 1 And $iValueB = 1 Then $sTest = "$iValue = 1 And $iValueB = 1" EndIf msgbox(0,"First demo Result",$sTest) If $iValueA = 1 Then $sTest = "$iValueA = 1" If $iValueB = 1 Then $sTest &= " And $iValueB = 1" EndIf EndIf msgbox(0,"Second demo Result",$sTest) Edited October 3, 2016 by spudw2k AutoBert 1 Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
romulocarlos Posted October 3, 2016 Author Posted October 3, 2016 Nevermind, solved. I change the lines with ElseIf @OSVersion = 'win_10' And @OSArch = 'x64' And @OSBuild < '11000' Then for normal version, and ElseIf @OSVersion = 'win_10' And @OSArch = 'x64' And @OSBuild > '11000' Then for Anniversary Edition. Is detecting fine, now.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now