Sign in to follow this  
Followers 0
StungStang

Registry Jump

19 posts in this topic

#1 ·  Posted (edited)

Hi to all, i am trying to opens registry editor (regedit.exe) in a specified hive.I have tried without luck But it just open regedit but it don't go nowhere ;)

This is the code:

_RegJump("HKEY_CURRENT_USERAppEvents")
Func _RegJump($sKey)
Local $Root, $Text = StringSplit($sKey, '', 2)
If IsArray($Text) Then
        $Text = $Text[0]
    Else
        $Text = $sKey
    EndIf
    Switch $Text
        Case 'HKEY_CLASSES_ROOT', 'HKEY_CURRENT_USER', 'HKEY_LOCAL_MACHINE', 'HKEY_USERS', 'HKEY_CURRENT_CONFIG'
            $Root = $Text
        Case 'HKCR'
            $Root = 'HKEY_CLASSES_ROOT'
        Case 'HKCU'
            $Root = 'HKEY_CURRENT_USER'
        Case 'HKLM'
            $Root = 'HKEY_LOCAL_MACHINE'
        Case 'HKU'
            $Root = 'HKEY_USERS'
        Case 'HKCC'
            $Root = 'HKEY_CURRENT_CONFIG'
        Case Else
            Return 0
    EndSwitch[/color][/font]
[font="helvetica, arial, sans-serif"][color="#282828"]  Local $Class = '[CLASS:RegEdit_RegEdit]', $Delay = Opt('WinWaitDelay', 0)
    Local $Prev, $Result = 1[/color][/font]
[font="helvetica, arial, sans-serif"][color="#282828"]  If WinExists($Class) Then
        WinClose($Class)
        If Not WinWaitClose($Class, '', 5) Then
            $Result = 0
        EndIf
    EndIf
    If $Result Then
        $Prev = RegRead('HKCUSoftwareMicrosoftWindowsCurrentVersionAppletsRegedit', 'Lastkey')
        If @error Then
            $Prev = 0
        EndIf
        If Not RegWrite('HKCUSoftwareMicrosoftWindowsCurrentVersionAppletsRegedit', 'Lastkey', 'REG_SZ', StringReplace($sKey, $Text, $Root, 1)) Then
            $Result = 0
        Else
            If Not Run('regedit.exe') Then
                $Result = 0
                If IsString($Prev) Then
                    RegWrite('HKCUSoftwareMicrosoftWindowsCurrentVersionAppletsRegedit', 'Lastkey', 'REG_SZ', $Prev)
                EndIf
            EndIf
        EndIf
    EndIf
    Opt('WinWaitDelay', $Delay)
    Return $Result
EndFunc   ;==>_RegJump

I have tried several registry key but without luck, how i can fix that?

Hi

Edited by StungStang

Share this post


Link to post
Share on other sites



Checkout the RegEdit Jumper at the bottom of my post. It utilizes the _RegJump() that Yashied created.


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.  

Share this post


Link to post
Share on other sites

Same issue, it jusp open regedit ;)

P.S. Your code seems to be buggy, there is an unused Wend at line 97. So after you press "Open" button, the script stuck, like a continue loop :)

Hi!

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

It does open RegEdit as you requested. No one ever mentioned the error to me before, I do apologize. It is now fixed.

My jumper only provides an interface to interact with Yashied's _RegJump() function. It allows you to either enumerate to a hive, or type the hive directly.

If you still have the script you copied and pasted from my post, you will see that an addition 'WEnd' was placed in the main loop. If you remove that line it will work as intended, or you can attempt to cut n paste from my original post where I have now amended it.

I did not suggest that my example was your final solution, but that you could see how my code interacts with Yashied's _RegJump() and that it may give you an idea of how to implement his function into your code.

I'm also sorry I didn't see what was breaking your code the first time. However, Remove the trailing backward slash ', and your code should work as intended.

_RegJump("HKEY_CURRENT_USERAppEvents") ;<--Correct
_RegJump("HKEY_CURRENT_USERAppEvents") ;<--Remove the trailing backward slash

Good Luck and Happy Coding!

Realm

Edit: Typo

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.  

Share this post


Link to post
Share on other sites

_RegJump won't work, it only open regedit !

Anyway thanks for your help

Hi!

Share this post


Link to post
Share on other sites

Works on my end. did you change "HKEY_CURRENT_USERAppEvents" to "HKEY_CURRENT_USERAppEvents"?


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.  

Share this post


Link to post
Share on other sites

Try ! ;)


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

@wakillon

I cant run you script with autoit 3.3.8.1. I've this error:

AutoIt3IncludeWinAPIEx.au3(6661,104) : ERROR: _WinAPI_DuplicateHandle() already defined.

Hi!

Share this post


Link to post
Share on other sites

May be you need to update ;)


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

Yes fixed, but nothing changes, it's only open regedit but don't go the the specific hive ;)

Do you have some suggestion?

Hi!

Share this post


Link to post
Share on other sites

HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionAppletsRegedit

Is this reg key exists ?


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

yes exists. I also have tried a lot and lot existing key but same story. It only open regedit ;)

Hi!

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Ok, and what is his "LastKey" value ?

Posted Image

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

This is what the LastKey value located in "HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionAppletsRegedit" contain:

My ComputerHKEY_CLASSES_ROOT

Hi! and thanks for the help ;)

Share this post


Link to post
Share on other sites

May be you don't have permission for edit registry

try this

$_Var = _RegEditorSetLastKey ( 'HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionAppletsRegedit' )
ConsoleWrite ( @error & " : " & $_Var & @Crlf )

Func _RegEditorSetLastKey ( $_RegKey )
    Return RegWrite ( 'HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionAppletsRegedit', 'Lastkey', 'REG_SZ', $_RegKey )
EndFunc ;==> _RegEditorSetLastKey ( )

You can also right click on a regitry key and look to the "authorization" for see if you have full control.


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

Maybe i have understand the issue ;)

I've write this function:

Func _My_Reg_Jump($rVal)
If @OSArch = 'X86' Then
  $_RegeditKey = 'HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionAppletsRegedit'
Else
  $_RegeditKey = 'HKEY_CURRENT_USER64SoftwareMicrosoftWindowsCurrentVersionAppletsRegedit'
EndIf
If ProcessExists("regedit.exe") Then
  ProcessClose("regedit.exe")
EndIf
RegDelete($_RegeditKey, "Lastkey")
RegWrite($_RegeditKey, "Lastkey", "REG_SZ", $rVal)
If Not @error Then
  ShellExecute("regedit.exe")
  Return True
Else
  Return False
EndIf
EndFunc   ;==>_My_Reg_Jump

Now for example if i run this command:

_My_Reg_Jump("HKEY_CURRENT_USERSoftwareAutoIt v3")

The function just open the regedit and the LastKey contain this:

HKEY_CURRENT_USERSoftwareAutoIt v3

But if i run the function in this way:

_My_Reg_Jump("My ComputerHKEY_CURRENT_USERSoftwareAutoIt v3")

All work good.

N.B. I've add "My Computer" before the key that i want display, and its work!. Now there is a problem. If i change pc i cannot know what string i've to put before the key that i want display. There is a way to know that?

Hi!

Edited by StungStang

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

Try this and see if it works for you...

_RegJumpTo('HKEY_LOCAL_MACHINESOFTWAREMicrosoft')

Func _RegJumpTo($sKey)
    If Not (StringLeft($sKey, 4) = 'HKEY') Then
        Return SetError(-1, 0, -1)
    EndIf
    If ProcessExists('regedit.exe') Then
        WinClose('Registry Editor'); try winclose first (should close here in most cases)
        Sleep(20)
        If ProcessExists('regedit.exe') Then
            ProcessClose('regedit.exe'); if winclose fails then processclose
        EndIf
    EndIf
    If (StringRight($sKey, 1) = '') Then
        $sKey = StringTrimRight($sKey, 1)
    EndIf
    Local $sREK = 'HKEY_CURRENT_USER64SoftwareMicrosoftWindowsCurrentVersionAppletsRegedit'
    If (@OSArch = 'X86') Then
        $sREK = StringReplace($sREK, '64', ''); known key
    EndIf
    Local $a = StringSplit($sKey, '', 1)
    If (StringRight($a[1], 2) = '64') Then
        $sKey = StringReplace($sKey, $a[1], StringReplace($a[1], '64', '')); unknown key
    EndIf
    If RegWrite($sREK, 'LastKey', 'Reg_SZ', 'Computer' & $sKey) Then
        ShellExecute(@WindowsDir & 'regedit.exe')
    EndIf
EndFunc

-EDIT-

oops - code edit

StringReplace($a[1], '64') --> StringReplace($a[1], '64', '')

Edited by ripdad

"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Share this post


Link to post
Share on other sites

@ripdad

This seems to work, i will test later on another machine, hoping that's work for all pc that run the script.

Hi! and Thanks!

Share this post


Link to post
Share on other sites

it should work for all machines.

please re-copy the code - I fixed a small mistake in it.

was in a hurry - thats what I get.

should be okay now.


"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Share this post


Link to post
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
Sign in to follow this  
Followers 0