Jump to content

Registry Jump


Recommended Posts

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
Link to comment
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. 

Link to comment
Share on other sites

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. 

Link to comment
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. 

Link to comment
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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

Link to comment
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

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