antmar904 Posted October 11, 2017 Share Posted October 11, 2017 Hi All, I'm trying to see if .Net 4.6.1 or higher is already installed but I'm having issues with this. I origanlly would query the uninstall path in the registry but then any .Net updates would show so that won't work so I guess the next step would be to try and look for the exe file paths. Here i'm trying to see if .Net 4.6.1 or higher is installed but it's not working. #RequireAdmin #include <FileConstants.au3> #include <Array.au3> #include <File.au3> If @OSArch = "X64" Then $DotNetPath = "C:\Windows\Microsoft.NET\Framework64\" Else $DotNetPath = "C:\Windows\Microsoft.NET\Framework\" EndIf $FolderList = _FileListToArray($DotNetPath, "*", 2) _ArrayDisplay($FolderList) For $i = 1 To UBound($FolderList) - 1 $NewList = StringTrimLeft($FolderList[$i], 1) ;<--- Removes the "v" at the beginning of the string ConsoleWrite("Is " & $NewList & " greater than 4" & @CRLF) If $NewList > "4" Then $FolderList2 = _FileListToArray($DotNetPath & "\" & $FolderList[$i] & "\SetupCache", "*", 2) _ArrayDisplay($FolderList2) Else MsgBox(0, "", "no .net 4.0 found") Exit EndIf Next Link to comment Share on other sites More sharing options...
Earthshine Posted October 11, 2017 Share Posted October 11, 2017 (edited) I can tell you that InstallShield prerequisites use the uninstall registry key. I have no idea what you mean when you say all updates would show? after installing I find the following: That GUID, if you find it (GLOBAL UNIQUE IDENTIFIER so no others will be this one, update or not) {BD6F5371-DAC1-30F0-9DDE-CAC6791E28C3} Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{BD6F5371-DAC1-30F0-9DDE-CAC6791E28C3}] "AuthorizedCDFPrefix"="" "Comments"="" "Contact"="" "DisplayVersion"="4.6.01055" "HelpLink"="" "HelpTelephone"="" "InstallDate"="20171011" "InstallLocation"="" "InstallSource"="D:\\48316e20371c96bacf\\" "ModifyPath"=hex(2):4d,00,73,00,69,00,45,00,78,00,65,00,63,00,2e,00,65,00,78,\ 00,65,00,20,00,2f,00,58,00,7b,00,42,00,44,00,36,00,46,00,35,00,33,00,37,00,\ 31,00,2d,00,44,00,41,00,43,00,31,00,2d,00,33,00,30,00,46,00,30,00,2d,00,39,\ 00,44,00,44,00,45,00,2d,00,43,00,41,00,43,00,36,00,37,00,39,00,31,00,45,00,\ 32,00,38,00,43,00,33,00,7d,00,00,00 "NoModify"=dword:00000001 "NoRepair"=dword:00000001 "Publisher"="Microsoft Corporation" "Readme"=hex(2):68,00,74,00,74,00,70,00,3a,00,2f,00,2f,00,67,00,6f,00,2e,00,6d,\ 00,69,00,63,00,72,00,6f,00,73,00,6f,00,66,00,74,00,2e,00,63,00,6f,00,6d,00,\ 2f,00,66,00,77,00,6c,00,69,00,6e,00,6b,00,2f,00,3f,00,4c,00,69,00,6e,00,6b,\ 00,49,00,64,00,3d,00,36,00,37,00,31,00,37,00,34,00,32,00,00,00 "Size"=dword:00009b34 "EstimatedSize"=dword:00136843 "SystemComponent"=dword:00000001 "UninstallString"=hex(2):4d,00,73,00,69,00,45,00,78,00,65,00,63,00,2e,00,65,00,\ 78,00,65,00,20,00,2f,00,58,00,7b,00,42,00,44,00,36,00,46,00,35,00,33,00,37,\ 00,31,00,2d,00,44,00,41,00,43,00,31,00,2d,00,33,00,30,00,46,00,30,00,2d,00,\ 39,00,44,00,44,00,45,00,2d,00,43,00,41,00,43,00,36,00,37,00,39,00,31,00,45,\ 00,32,00,38,00,43,00,33,00,7d,00,00,00 "URLInfoAbout"="http://go.microsoft.com/fwlink/?LinkId=286133" "URLUpdateInfo"="http://go.microsoft.com/fwlink/?LinkId=286134" "VersionMajor"=dword:00000004 "VersionMinor"=dword:00000006 "WindowsInstaller"=dword:00000001 "Version"=dword:0406041f "Language"=dword:00000000 "DisplayName"="Microsoft .NET Framework 4.6.1" Edited October 11, 2017 by Earthshine My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted October 11, 2017 Moderators Share Posted October 11, 2017 I typically let these kinds of tasks fall to WMI: Local $oWMI = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") Local $oItems = $oWMI.ExecQuery("Select * FROM Win32_Product Where name like '%%.NET%%'") For $sItem In $oItems ConsoleWrite($sItem.Version & @CRLF) Next "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Earthshine Posted October 11, 2017 Share Posted October 11, 2017 (edited) One more thing, in your code, you assume windows installed to C:\ Well, hate to tell you this, but it can be installed to any fixed drive so your code will fail there on a non-standard installation. You should look that up the system drive. if you find the key {BD6F5371-DAC1-30F0-9DDE-CAC6791E28C3} under the uninstall folders, you know you got 4.6.1 installed or later versions of 4.6, new versions will have their own GUID A simple RegRead at the uninstall key would give you what you are looking for. Edited October 11, 2017 by Earthshine My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
antmar904 Posted October 11, 2017 Author Share Posted October 11, 2017 16 minutes ago, Earthshine said: I can tell you that InstallShield prerequisites use the uninstall registry key. I have no idea what you mean when you say all updates would show? after installing I find the following: That GUID, if you find it (GLOBAL UNIQUE IDENTIFIER so no others will be this one, update or not) {BD6F5371-DAC1-30F0-9DDE-CAC6791E28C3} Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{BD6F5371-DAC1-30F0-9DDE-CAC6791E28C3}] "AuthorizedCDFPrefix"="" "Comments"="" "Contact"="" "DisplayVersion"="4.6.01055" "HelpLink"="" "HelpTelephone"="" "InstallDate"="20171011" "InstallLocation"="" "InstallSource"="D:\\48316e20371c96bacf\\" "ModifyPath"=hex(2):4d,00,73,00,69,00,45,00,78,00,65,00,63,00,2e,00,65,00,78,\ 00,65,00,20,00,2f,00,58,00,7b,00,42,00,44,00,36,00,46,00,35,00,33,00,37,00,\ 31,00,2d,00,44,00,41,00,43,00,31,00,2d,00,33,00,30,00,46,00,30,00,2d,00,39,\ 00,44,00,44,00,45,00,2d,00,43,00,41,00,43,00,36,00,37,00,39,00,31,00,45,00,\ 32,00,38,00,43,00,33,00,7d,00,00,00 "NoModify"=dword:00000001 "NoRepair"=dword:00000001 "Publisher"="Microsoft Corporation" "Readme"=hex(2):68,00,74,00,74,00,70,00,3a,00,2f,00,2f,00,67,00,6f,00,2e,00,6d,\ 00,69,00,63,00,72,00,6f,00,73,00,6f,00,66,00,74,00,2e,00,63,00,6f,00,6d,00,\ 2f,00,66,00,77,00,6c,00,69,00,6e,00,6b,00,2f,00,3f,00,4c,00,69,00,6e,00,6b,\ 00,49,00,64,00,3d,00,36,00,37,00,31,00,37,00,34,00,32,00,00,00 "Size"=dword:00009b34 "EstimatedSize"=dword:00136843 "SystemComponent"=dword:00000001 "UninstallString"=hex(2):4d,00,73,00,69,00,45,00,78,00,65,00,63,00,2e,00,65,00,\ 78,00,65,00,20,00,2f,00,58,00,7b,00,42,00,44,00,36,00,46,00,35,00,33,00,37,\ 00,31,00,2d,00,44,00,41,00,43,00,31,00,2d,00,33,00,30,00,46,00,30,00,2d,00,\ 39,00,44,00,44,00,45,00,2d,00,43,00,41,00,43,00,36,00,37,00,39,00,31,00,45,\ 00,32,00,38,00,43,00,33,00,7d,00,00,00 "URLInfoAbout"="http://go.microsoft.com/fwlink/?LinkId=286133" "URLUpdateInfo"="http://go.microsoft.com/fwlink/?LinkId=286134" "VersionMajor"=dword:00000004 "VersionMinor"=dword:00000006 "WindowsInstaller"=dword:00000001 "Version"=dword:0406041f "Language"=dword:00000000 "DisplayName"="Microsoft .NET Framework 4.6.1" @Earthshine I mean if I query the uninstall path in the registry and look for "microsoft .net framework" that it will also show me any .net updates that have been installed. I usually query the uninstall path for programs that typically do not receive updates. Link to comment Share on other sites More sharing options...
Earthshine Posted October 11, 2017 Share Posted October 11, 2017 Here is a little utility someone in the forums wrote, I am pretty sure. You can mod it for getting the latest versions if you wish. GetDotNetVersions.au3 My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
antmar904 Posted October 11, 2017 Author Share Posted October 11, 2017 10 minutes ago, Earthshine said: One more thing, in your code, you assume windows installed to C:\ Well, hate to tell you this, but it can be installed to any fixed drive so your code will fail there on a non-standard installation. You should look that up the system drive. if you find the key {BD6F5371-DAC1-30F0-9DDE-CAC6791E28C3} under the uninstall folders, you know you got 4.6.1 installed or later versions of 4.6, new versions will have their own GUID A simple RegRead at the uninstall key would give you what you are looking for. @Earthshine Thanks however in my environment all of our workstations have Windows installed on C:\. Link to comment Share on other sites More sharing options...
antmar904 Posted October 11, 2017 Author Share Posted October 11, 2017 12 minutes ago, JLogan3o13 said: I typically let these kinds of tasks fall to WMI: Local $oWMI = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") Local $oItems = $oWMI.ExecQuery("Select * FROM Win32_Product Where name like '%%.NET%%'") For $sItem In $oItems ConsoleWrite($sItem.Version & @CRLF) Next @JLogan3o13 I forgot about WMI! Thanks Ill most likely go this route. Link to comment Share on other sites More sharing options...
antmar904 Posted October 11, 2017 Author Share Posted October 11, 2017 3 minutes ago, Earthshine said: Here is a little utility someone in the forums wrote, I am pretty sure. You can mod it for getting the latest versions if you wish. GetDotNetVersions.au3 Great thank you for this, it's a bit overkill for what I need but good to have. Earthshine 1 Link to comment Share on other sites More sharing options...
Earthshine Posted October 11, 2017 Share Posted October 11, 2017 Just now, antmar904 said: @Earthshine I mean if I query the uninstall path in the registry and look for "microsoft .net framework" that it will also show me any .net updates that have been installed. I usually query the uninstall path for programs that typically do not receive updates. No, look for that GUID key under the uninstall key. You could even look up Display Name. $variable = RegRead (' HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{BD6F5371-DAC1-30F0-9DDE-CAC6791E28C3} ', 'DisplayName') If (StringLen($variable) > 0) Then Do something EndIf is all you need. My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
Earthshine Posted October 11, 2017 Share Posted October 11, 2017 (edited) WMI has dependencies that are not always installed. the posted WMI code above does nothing on any of my VMs or machines. I always steer clear of that. Too cryptic as well. Edited October 11, 2017 by Earthshine My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
junkew Posted October 11, 2017 Share Posted October 11, 2017 The coding in itself is incorrect Check stripws function Check stringleft function after you stripped the whitespace Check on if stringleft of first 2 chars equals v4 And ms has more doc on this then coding you need See https://docs.microsoft.com/en-us/dotnet/framework/migration-guide/how-to-determine-which-versions-are-installed Danyfirex 1 FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
Matt_Murdoch Posted October 11, 2017 Share Posted October 11, 2017 (edited) So, someone here wrote RegSearch I wrote a test to see how easy it is to enumerate through the reg and find what you want. this finds all strings of .NET Framework 4.whatever.this finds all strings of .NET Framework 4.whatever. RegSearch can be obtained here, get the latest version log4a here: #include <MsgBoxConstants.au3> #include "log4a.au3" #include "RegSearch.au3" #Region ;**** Logging **** ; Enable logging and don't write to stderr _log4a_SetEnable() ; Write to stderr, set min level to warn, customize message format _log4a_SetErrorStream() _log4a_SetMinLevel($LOG4A_LEVEL_INFO) ; If @compiled Then _log4a_SetMinLevel($LOG4A_LEVEL_WARN) ; Change the min level if the script is compiled _log4a_SetFormat("${date} | ${host} | ${level} | ${message}") #EndRegion ;**** Logging **** Local $var = _RegSearch('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall', '.NET Framework 4.') _log4a_Info($var) SearchForNET.au3 Edited October 11, 2017 by Matt_Murdoch Link to comment Share on other sites More sharing options...
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