Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

Check Software Location From The Registry


  • Please log in to reply
1 reply to this topic

#1 Chimaera

Chimaera

    Sorry .. Where am i again?

  • Active Members
  • PipPipPipPipPipPip
  • 2,015 posts

Posted 17 October 2011 - 03:47 PM

This is me giving a little back for all the help i recieve.

This wont be off use for everyone, and any contributions to make it badass are always gratefully accepted :graduated:

I use this in a script that has separate #install scripts for each product, its called to determine the install location of a given product on a system.
Before i perform other checks on that product.
It checks the InstallLocation key first and if it doesn't exist (which they often don't), then it looks for the UninstallString and deducts the stuff of the end of the string to give you the path.

Im no genius with coding but i hope it helps someone
It prob needs some error checking etc but its where i am atm

AutoIt         
#cs ----------------------------------------------------------------------------       AutoIt Version: 3.3.6.1     Author:      Chimaera     Script Function: Find Install Location From Registry Key Name     Instructions: I use this to determine path after a registry check for #include sheets to a bigger script.       Credits And Thanks: guinness, Jfx, UEZ, Geosoft #ce ---------------------------------------------------------------------------- #RequireAdmin Global $InstallLocation ;<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>> DAEMON Tools Lite, CCleaner $regkey = 'CCleaner' ;<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>> $StringFirst = "InstallLocation" $StringSecond = "UninstallString" $path_1 = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Uninstall\" & $regkey $path_2 = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & $regkey $path_3 = "HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & $regkey $path_4 = "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\" & $regkey ;<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>> _CheckSoftwareLocation() ;<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>   MsgBox(0, "Install Location", $InstallLocation)   ;<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>> Func _CheckSoftwareLocation()     Select         Case _IsRegistryExist($path_1, $StringFirst) = 1 Or _IsRegistryExist($path_2, $StringFirst) = 1 Or _IsRegistryExist($path_3, $StringFirst) = 1 Or _IsRegistryExist($path_4, $StringFirst) = 1             If _IsRegistryExist($path_1, $StringFirst) = 1 Then                 $soft_path = RegRead($path_1, $StringFirst)                 $InstallLocation = _GetDirectoryFormat($soft_path, 1)                 ConsoleWrite("I1 " & $InstallLocation & @CRLF)             ElseIf _IsRegistryExist($path_2, $StringFirst) = 1 Then                 $soft_path = RegRead($path_2, $StringFirst)                 $InstallLocation = _GetDirectoryFormat($soft_path, 1)                 ConsoleWrite("I2 " & $InstallLocation & @CRLF)             ElseIf _IsRegistryExist($path_3, $StringFirst) = 1 Then                 $soft_path = RegRead($path_3, $StringFirst)                 $InstallLocation = _GetDirectoryFormat($soft_path, 1)                 ConsoleWrite("I3 " & $InstallLocation & @CRLF)             ElseIf _IsRegistryExist($path_4, $StringFirst) = 1 Then                 $soft_path = RegRead($path_4, $StringFirst)                 $InstallLocation = _GetDirectoryFormat($soft_path, 1)                 ConsoleWrite("I4 " & $InstallLocation & @CRLF)             EndIf         Case Else             If _IsRegistryExist($path_1, $StringSecond) = 1 Then                 $soft_path = RegRead($path_1, $StringSecond)                 $InstallLocation = StringRegExpReplace($soft_path, "^(.*)\\.*$", "$1\\")                 ConsoleWrite("U1 " & $InstallLocation & @CRLF)             ElseIf _IsRegistryExist($path_2, $StringSecond) = 1 Then                 $soft_path = RegRead($path_2, $StringSecond)                 $InstallLocation = StringRegExpReplace($soft_path, "^(.*)\\.*$", "$1\\")                 ConsoleWrite("U2 " & $InstallLocation & @CRLF)             ElseIf _IsRegistryExist($path_3, $StringSecond) = 1 Then                 $soft_path = RegRead($path_3, $StringSecond)                 $InstallLocation = StringRegExpReplace($soft_path, "^(.*)\\.*$", "$1\\")                 ConsoleWrite("U3 " & $InstallLocation & @CRLF)             ElseIf _IsRegistryExist($path_4, $StringSecond) = 1 Then                 $soft_path = RegRead($path_4, $StringSecond)                 $InstallLocation = StringRegExpReplace($soft_path, "^(.*)\\.*$", "$1\\")                 ConsoleWrite("U4 " & $InstallLocation & @CRLF)             EndIf     EndSelect EndFunc   ;==>_CheckSoftwareLocation ;<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>> Func _IsRegistryExist($sKeyName, $sValueName); 0 = Doesn't Exist / 1 = Exists [Author guinness]     RegRead($sKeyName, $sValueName)     Return Number(@error = 0) EndFunc   ;==>_IsRegistryExist ;<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>> Func _GetDirectoryFormat(ByRef $sDirectory, $iAppend = 1, $iFlag = 0) ;  [Author guinness]     Local $sAppend = ""     If $iAppend Then         $sAppend = "\"     EndIf     $sDirectory = StringRegExpReplace($sDirectory, "[\\/]+\z", "") & $sAppend     If FileExists($sDirectory) = 0 And $iFlag Then         DirCreate($sDirectory)     EndIf     Return SetError(0, 0, $sDirectory) EndFunc   ;==>_GetDirectoryFormat ;<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>


Updated Main Post

Edited by Chimaera, 17 October 2011 - 04:04 PM.

If Ive just helped you ... miracles do happen. Chimaera 

 

CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices()








#2 guinness

guinness

    all-consuming swarm in inconspicuous disguise

  • Developers
  • 17,640 posts

Posted 17 October 2011 - 03:58 PM

My simplified version of _IsRegistryExist()

Func _IsRegistryExist($sKeyName, $sValueName)     RegRead($sKeyName, $sValueName)     Return Number(@error = 0) EndFunc   ;==>_IsRegistryExist

Edited by guinness, 17 October 2011 - 04:00 PM.

Example List: _AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_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()CodingDirToHTML5FileInstallrGeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()LockFile()Mapping CtrlIDsParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...
Updated: 26/09/2014





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users