Jump to content

SearchReg-example


Holger
 Share

Recommended Posts

Hi

Thanks, I did say I was new to this...

One more thing, is it possible to add a search to this, si it searches like this...

1st search = HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall

2nd search = Display name or software name

3rd search = UninstallString

thanks for all the help

Keith

Link to comment
Share on other sites

Also, how would I have the output as a value[string] rather than an array?

You might read the header of the function for the input parameters, one of them is related.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Hi

I came up with this, but it fails

#include <Array.au3>

Global $sUninstallKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"

Global $sValName = "Flare"

Global $sValData = "UninstallString"

; Get array of all "UninstallString" values

$aUninstallKeys = _RegSearch($sUninstallKey, $sValName, $sValData, 4, True) ; 2 = Match on Value Names only, True = return array

; Create 2D array for data

Global $aUninstallStrings[uBound($aUninstallKeys)][2] = [[$aUninstallKeys[0], ""]]

; Populate 2D array with value location and data

For $n = 2 To $aUninstallKeys[0]

$aUninstallStrings[$n][0] = $aUninstallKeys[$n]

$aUninstallStrings[$n][1] = RegRead(StringTrimRight($aUninstallStrings[$n][0], StringLen($sValName)), $sValName)

$aUninstallStrings[$n][2] = RegRead(StringTrimRight($aUninstallStrings[$n][0], StringLen($sValData)), $sValData)

Next

Link to comment
Share on other sites

You still haven't read the header to the function for proper syntax. Hint: You are calling _RegSearch() with five input parameters when it only takes four.

Maybe you need to work a little more with the tutorials and learn some more basic syntax before you tackle this project.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Thanks44As I say I am very now to this

You say I can use only four parameters, does this mean I connot search the way I want ie

1st search = HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall

2nd search = Display name or software name

3rd search = UninstallString

Or am I just doing it worng?

Thanks for you help PsaltyDS

Keith

Link to comment
Share on other sites

I have now added a second array

array 1 gives 2 results

array 2 gives 2 results

between the 2 I have the 3 required, I just need to merge the 2, or add a section to one, thia is what I have up to now

#include <Array.au3>

Global $sUninstallKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
Global $sValName = "UninstallString"
Global $sName = "DisplayName"

; Get array of all "UninstallString" values
$aUninstallKeys = _RegSearch($sUninstallKey, $sValName, 2, True) ; 2 = Match on Value Names only, True = return array
$aUninstallKeys2 = _RegSearch($sUninstallKey, $sName, 2, True) ; 2 = Match on Value Names only, True = return array

; Create 2D array for data
Global $aUninstallStrings[UBound($aUninstallKeys)][2] = [[$aUninstallKeys[0], ""]]
Global $aUninstallStrings2[UBound($aUninstallKeys2)][3] = [[$aUninstallKeys2[0], ""]]

; Populate 2D array with value location and data
For $n = 3 To $aUninstallKeys[0]
    $aUninstallStrings[$n][0] = $aUninstallKeys[$n]
    $aUninstallStrings[$n][1] = RegRead(StringTrimRight($aUninstallStrings[$n][0], StringLen($sValName)), $sValName)
    $aUninstallStrings2[$n][2] = RegRead(StringTrimRight($aUninstallStrings2[$n][0], StringLen($sName)), $sName)

Next


for $n = 3 To $aUninstallKeys2[0]
    $aUninstallStrings2[$n][0] = $aUninstallKeys2[$n]
    $aUninstallStrings2[$n][1] = RegRead(StringTrimRight($aUninstallStrings2[$n][0], StringLen($sName)), $sName)
Next


; Display results
_ArrayDisplay($aUninstallStrings)
_ArrayDisplay($aUninstallStrings2)
Link to comment
Share on other sites

  • 2 months later...

Hello

Your code at #10 is great. I used it to locate where "TNSNAMES.ora" files should be.

Thank's a lot, it works well.

I may suggest you a litte enhancement : I have to locate "ORACLE_HOME" entries, but retrieve the contents of the registry entries.

today, the code looks like this, and has you can see, it's a little bit complicated to get the values.

Dim $CLE_INSTALLATION_ORACLE
$CLE_INSTALLATION_ORACLE=_RegSearch("HKLM\Software\Oracle","ORACLE_HOME",2,True)
 
For $CPT = 1 To $CLE_INSTALLATION_ORACLE[0]
 
$TEST=StringInStr($CLE_INSTALLATION_ORACLE[$CPT],"\",0,-1)
$KEYCHEM=StringLeft($CLE_INSTALLATION_ORACLE[$CPT],$TEST-1)
$KEYVAL=StringMid($CLE_INSTALLATION_ORACLE[$CPT],$TEST+1)
$TEST=RegRead($KEYCHEM,$KEYVAL)
 
 
$TNSFIC=$TEST & "\network\admin\tnsnames.ora"
If FileExists($TNSFIC) Then

It would be nice to have an option to get an array of values, instead an array of regkeys...

Link to comment
Share on other sites

It would be nice to have an option to get an array of values, instead an array of regkeys...

I don't see why you find that complicated. Wrap it in a UDF to make it easy to use:

#include <Array.au3> ; Only for _ArrayDisplay()
 
Global $aInstallDirs = _RegSearch("HKLM\Software\AutoIt v3", "InstallDir", 2, True)
Global $aInstallDirData = _RegGetDataArray($aInstallDirs)
_ArrayDisplay($aInstallDirData)
 
 
Func _RegGetDataArray($aVals)
    Local $iDelim, $aRET[$aVals[0] + 1][3] = [[$aVals[0], "", ""]]
    For $i = 1 To $aVals[0]
          $iDelim = StringInStr($aVals[$i], "\", 0, -1)
          $aRET[$i][0] = StringLeft($aVals[$i], $iDelim - 1)
          $aRET[$i][1] = StringMid($aVals[$i], $iDelim + 1)
          $aRET[$i][2] = RegRead($aRET[$i][0], $aRET[$i][1])
    Next
    Return $aRET
EndFunc   ;==>_RegGetDataArray

Edit: Restored code formatting. Wow, it's hard to overstate how much the new code tags suck in the new forum editor. :D

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

  • 5 months later...

@PsaltyDS

How do you specify the ROOT of the registry?

Above HKLM, HKCR, etc.

To allow your UDF to search the entire registry without having to call the function 5 times looking for the key/value in each separate HKLM, HKCR tree.

Link to comment
Share on other sites

@PsaltyDS

How do you specify the ROOT of the registry?

Above HKLM, HKCR, etc.

To allow your UDF to search the entire registry without having to call the function 5 times looking for the key/value in each separate HKLM, HKCR tree.

I'm going to continue trolling you here by stating fact.

Just like we told you there's no secret magical hidden key base under hklm or hkcu.

I'd recommend you make a trip to microsoft head quarters and start slapping some people.

Don't you think the author of this script would have implemented this kind of recursion had it been available? Also, how are you so sure the gui you mentioned (yet provided no insight into what it was) is making use of such a magical oneiric registry key?

Link to comment
Share on other sites

I'm going to continue trolling you here by stating fact.

Just like we told you there's no secret magical hidden key base under hklm or hkcu.

I disagree. There is.. its called "Computer"

Also, how are you so sure the gui you mentioned (yet provided no insight into what it was) is making use of such a magical oneiric registry key?

Seriously, you don't know what GUI I'm talking about? It's called REGEDIT.

And it's not magic. Like you said, please go troll somewhere else.

Link to comment
Share on other sites

I disagree. There is.. its called "Computer"

Seriously, you don't know what GUI I'm talking about? It's called REGEDIT.

And it's not magic. Like you said, please go troll somewhere else.

As stated in the thread linked, that you started, I posted a link to the MSDN page that tells you that you can't use RegEnumVal without one of the 5 key names, it's impossible. There may be another function that can access it that Microsoft knows about, but I didn't find any references to it.

BTW, how do YOU know that Microsoft doesn't search each key one at a time when you do a registry search in Regedit? It can take an awfully long time to search the registry, so I'm guessing that MIGHT be how they're doing it too.

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

Link to comment
Share on other sites

I disagree. There is.. its called "Computer"

Don't be naive. 'Computer' is a fabrication of regedit's GUI. It doesn't exist in the physical registry. Go to C:\Windows\System32\Config and tell me if you see 'Computer'. It might as well be called Cupcake.
Link to comment
Share on other sites

Link to comment
Share on other sites

  • 1 month later...

robinsiebler

#include <Array.au3>
#include "_RegSearch.au3"
$timer = TimerInit()
$Array = _RegSearchValueName('DisplayName', 'HKLMSOFTWAREMicrosoftWindowsCurrentVersionInstallerUserDataS-1-5-18Products', 0, 1)
If @error Then MsgBox(0, 'Сообщение', 'Ошибка, @error = ' & @error)
_ArrayDisplay($Array, 'time : ' & Round(TimerDiff($timer) / 1000, 2) & ' sec')
ReDim $Array[$Array[0][0] + 1][3]
For $i = 1 To $Array[0][0]
$Array[$i][2] = _RegRead($Array[$i][0], $Array[$i][1])
Next
_ArrayDisplay($Array, '-')
$ind = _ArraySearch($Array, '0', 1, 0, 0, 1, 1, 2)
If @error Then
MsgBox(4096, "Error", '-')
Else
MsgBox(4096, "Yes", $Array[$ind][0] & @LF & $Array[$ind][1] & @LF & $Array[$ind][2])
EndIf
Link to comment
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
 Share

  • Recently Browsing   0 members

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