Jump to content

Rookie needs help with reg query


Recommended Posts

Hello

I am absolutely new to autoit that's why I need help.

I need to query the registry in order to get an InstallLocation. The InstallLocation has an uninstall.exe which has to be run before the complete folder InstallLocation gets deleted.

Reg key with the string InstallLocation:

HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionUninstallTest

I need to run the uninstall.exe

and the

delete the complete folder

I hope you can help me.

Thanks in advance

Edited by Mcrip
Link to comment
Share on other sites

  • Moderators

Hi, Mcrip, welcome to the forum. The help file is your friend. Look at the Registry Management section to see what options are open to you. Try some things out. If you get stuck, feel free to post your code here and we will help as we're able. ;)

"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

Hi, Mcrip, welcome to the forum. The help file is your friend. Look at the Registry Management section to see what options are open to you. Try some things out. If you get stuck, feel free to post your code here and we will help as we're able. ;)

I have tried several things. I need it very urgently without any msg boxes.

Have one here but it shows an MSG Box and I don't really know how to go on with deleting the folder. I am totally stuck.

#region ;**** Directives created by AutoIt3Wrapper_GUI ****

#AutoIt3Wrapper_Icon=H:InstallProgram FilesMcRipMcRip.ico

#AutoIt3Wrapper_Outfile=..Desktopuninstall.exe

#AutoIt3Wrapper_Compression=4

#AutoIt3Wrapper_Res_requestedExecutionLevel=highestAvailable

#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****

$sBase = "HKLMSOFTWAREMicrosoftWindowsCurrentVersionUninstall"

$iEval = 1

$sSearch = "Test"

While 1

$sUninst = ""

$sDisplay = ""

$sCurrent = RegEnumKey($sBase, $iEval)

If @error Then ExitLoop

$sKey = $sBase & $sCurrent

$sDisplay = RegRead($sKey, "DisplayName")

If StringRegExp($sDisplay, "(?i).*" & $sSearch & ".*") Then

$sUninst = RegRead($sKey, "UninstallString")

If $sUninst Then

If MsgBox(36, "Result", "Are you sure you want to uninstall " & _

$sDisplay & "?") = 6 Then RunWait($sUninst)

EndIf

EndIf

$iEval += 1

WEnd

Edited by Mcrip
Link to comment
Share on other sites

I was able to remove the MSG box.

$sBase = "HKLMSOFTWAREMicrosoftWindowsCurrentVersionUninstall"

$iEval = 1

$sSearch = "Test"

While 1

$sUninst = ""

$sDisplay = ""

$sCurrent = RegEnumKey($sBase, $iEval)

If @error Then ExitLoop

$sKey = $sBase & $sCurrent

$sDisplay = RegRead($sKey, "DisplayName")

If StringRegExp($sDisplay, "(?i).*" & $sSearch & ".*") Then

$sUninst = RegRead($sKey, "UninstallString")

If $sUninst Then

RunWait($sUninst)

EndIf

EndIf

$iEval += 1

WEnd

What do I have to do within this script to delete the InstallLocation. InstallLocation string is in the same reg key

Edited by Mcrip
Link to comment
Share on other sites

Hello Mcrip,

Pass the name of the application you are looking for into the my example below, and it will return an Uninstall String (path to the uninstaller) if there is one to be found, or it will set @error to 1 if not found.

Func _GetUninstallString($sApplicationName)
    For $i = 1 To 9999
        Local $var = RegEnumKey('HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionUninstall', $i)
        If @error <> 0 Then ExitLoop
        If RegRead( 'HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionUninstall' & $var, 'DisplayName' ) = $sApplicationName Then
            Return( RegRead( 'HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionUninstall' & $var, 'UninstallString' ) )
        EndIf
    Next
    Return SetError(1)
EndFunc

Good Luck & Happy Coding!

Realm

Edited by Realm

My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. 

Link to comment
Share on other sites

Thanks for your help. This scripting language is pretty hard to me.

Let's assume I want to start an application based on the registry.

The registry has the entry InstallLocation. In this InstallLocation on the drive there is a file called uninstall.exe which I want to call with the command /S.

After uninstalling the software the complete folder must be removed.

I want to do all this silently, because I have to add it to an uninstaller.

The reg key is: HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionUninstallTest

The String name is: InstallLocation

In this InstallLocation I have to call the uninstall.exe /S

After all this remove the InstallLocation.

All this without any MSG Boxes or error levels. I does not matter if the key does not exist.

I am totally stuck.

Link to comment
Share on other sites

First of all... AutoIt isn't that hard that I see you guys screaming about it. In fact, its simple enough that I mastered its basics within a month.

Use:

$UNINSTALL_LOC = RegRead("HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionUninstallTest", "InstallLocation")
RunWait("" & $UNINSTALL_LOC & " /S")

Dude, you are really stuck !!

PS: We are coders but helpers, not someone you could hire to write scripts for you. ;)

Edited by MKISH

----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

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...