Jump to content



Photo

Stuck in serious Registry serious problem! x64 vs x86

registry x64 windows 7

  • Please log in to reply
10 replies to this topic

#1 logmein

logmein

    Polymath

  • Active Members
  • PipPipPipPip
  • 214 posts

Posted 17 August 2012 - 06:29 AM

Hi there,
I am going to build a program to manage my startup programs. It work well on WinXP but when I upgrade my OS to Win 7, everything goes hell!
This is my sample code :

Plain Text         
#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Constants.au3> #include <ListViewConstants.au3> #include <GuiListView.au3> #include <String.au3> Global $startup_key_1 = 'HKCU64\Software\Microsoft\Windows\CurrentVersion\Run';x64 os Global $startup_key_2 = 'HKLM64\Software\Microsoft\Windows\CurrentVersion\Run';x64 os Global $startup_key_3 = 'HKCU\Software\Microsoft\Windows\CurrentVersion\Run' Global $startup_key_4 = 'HKLM\Software\Microsoft\Windows\CurrentVersion\Run' #Region ### START Koda GUI section ### Form=D:\Total USB Security 4\startup_form.kxf $formStartup = GUICreate("Startup Manager", 618, 326, 192, 125, BitOR($WS_CAPTION,$WS_POPUP,$WS_BORDER,$WS_CLIPSIBLINGS), BitOR($WS_EX_TOOLWINDOW,$WS_EX_WINDOWEDGE)) GUISetFont(10, 400, 0, "Arial") $listStartup = GUICtrlCreateListView("Program|Key|File", 8, 8, 602, 286) $hdlListStartup = GUICtrlGetHandle (-1) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 150) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 70) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 375) $btnRemoveStartup = GUICtrlCreateButton("&Remove", 424, 296, 91, 25, $WS_GROUP) $btnCloseStartupForm = GUICtrlCreateButton("&Close", 520, 296, 91, 25, $WS_GROUP) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### _GetStartupItem () while 1 $nMsg = GUIGetMsg () Switch $nMsg Case $btnCloseStartupForm Exit Case $btnRemoveStartup _RemoveStartupItem () EndSwitch WEnd Func _RemoveStartupItem() $select = _GUICtrlListView_GetSelectedIndices($hdlListStartup, True);get first item index If $select[0] <> 0 Then $key = _GUICtrlListView_GetItem($hdlListStartup, $select[1], 1) $program = _GUICtrlListView_GetItem($hdlListStartup, $select[1], 0);program[3] means program name RegDelete($key[3] & '\Software\Microsoft\Windows\CurrentVersion\Run', $program[3]) ;ConsoleWrite ($key[3] & '\Software\Microsoft\Windows\CurrentVersion\Run' & '[' & $program[3] & ']' & @CRLF) If Not @error Then _GUICtrlListView_DeleteItem($hdlListStartup, $select[1]) Else MsgBox(32, 'Startup Manager', 'Can''t remove the registry key. Please try again!', '', $formStartup) Return EndIf EndIf EndFunc Func _GetStartupItem() For $i = 1 To 100 $enum_key = RegEnumVal($startup_key_1, $i) If @error then ExitLoop $strRegRead = RegRead($startup_key_1, $enum_key) $strRegReplace = _StringBetween ($strRegRead,'"','"') If Not @error Then $add = _GUICtrlListView_AddItem($hdlListStartup, $enum_key) _GUICtrlListView_AddSubItem($hdlListStartup, $add, 'HKCU64', 1) _GUICtrlListView_AddSubItem($hdlListStartup, $add, $strRegReplace[0] , 2) Else $add = _GUICtrlListView_AddItem($hdlListStartup, $enum_key) _GUICtrlListView_AddSubItem($hdlListStartup, $add, 'HKCU64', 1) _GUICtrlListView_AddSubItem($hdlListStartup, $add, $strRegRead , 2) EndIf Next For $i = 1 To 100 $enum_key = RegEnumVal($startup_key_2, $i) If @error then ExitLoop $strRegRead = RegRead($startup_key_2, $enum_key) $strRegReplace = _StringBetween ($strRegRead,'"','"') If Not @error Then $add = _GUICtrlListView_AddItem($hdlListStartup, $enum_key) _GUICtrlListView_AddSubItem($hdlListStartup, $add, 'HKLM64', 1) _GUICtrlListView_AddSubItem($hdlListStartup, $add, $strRegReplace[0], 2) Else $add = _GUICtrlListView_AddItem($hdlListStartup, $enum_key) _GUICtrlListView_AddSubItem($hdlListStartup, $add, 'HKLM64', 1) _GUICtrlListView_AddSubItem($hdlListStartup, $add, $strRegRead , 2) EndIf Next For $i = 1 To 100 $enum_key = RegEnumVal($startup_key_3, $i) If @error then ExitLoop $strRegRead = RegRead($startup_key_3, $enum_key) $strRegReplace = _StringBetween ($strRegRead,'"','"') If Not @error Then $add = _GUICtrlListView_AddItem($hdlListStartup, $enum_key) _GUICtrlListView_AddSubItem($hdlListStartup, $add, 'HKLM', 1) _GUICtrlListView_AddSubItem($hdlListStartup, $add, $strRegReplace[0], 2) Else $add = _GUICtrlListView_AddItem($hdlListStartup, $enum_key) _GUICtrlListView_AddSubItem($hdlListStartup, $add, 'HKLM', 1) _GUICtrlListView_AddSubItem($hdlListStartup, $add, $strRegRead , 2) EndIf Next For $i = 1 To 100 $enum_key = RegEnumVal($startup_key_4, $i) If @error then ExitLoop $strRegRead = RegRead($startup_key_4, $enum_key) $strRegReplace = _StringBetween ($strRegRead,'"','"') If Not @error Then $add = _GUICtrlListView_AddItem($hdlListStartup, $enum_key) _GUICtrlListView_AddSubItem($hdlListStartup, $add, 'HKLM', 1) _GUICtrlListView_AddSubItem($hdlListStartup, $add, $strRegReplace[0], 2) Else $add = _GUICtrlListView_AddItem($hdlListStartup, $enum_key) _GUICtrlListView_AddSubItem($hdlListStartup, $add, 'HKLM', 1) _GUICtrlListView_AddSubItem($hdlListStartup, $add, $strRegRead , 2) EndIf Next Return EndFunc ;==>_GetStartupItem #endregion---------------------------------------------------------


My program can still detect x86 startup programs but when I try to remove x86 programs, there was error. Then I use CCleaner to check up, I choose a x86 program (iTunesHelper), then right-click and choose "Open in Regedit..." and I get the address of registry key : Computer\HLMC\SOFTWARE\Microsoft\Windows\CurrentVersion\Run. Remember that!

Posted Image

Posted Image

Afterthat, I choose a x64 program in CCleaner(Persistence), continue to view it in Regedit and I got this :

Posted Image

Posted Image

Still Computer\HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run??!

Plz help me!







#2 logmein

logmein

    Polymath

  • Active Members
  • PipPipPipPip
  • 214 posts

Posted 17 August 2012 - 07:41 AM

I need you help! As soon as possible, thanks! :bye:

#3 guinness

guinness

    guinness

  • MVPs
  • 10,439 posts

Posted 17 August 2012 - 07:49 AM

Congratulations on trying not to get help. Don't bump less than 24hours and use that time to find the answer yourself.

Example List: _AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_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()_GUISetIcon()_Icon_Clear()/_Icon_Set()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_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()_StringIsValid()_StringReplaceWholeWord()_StringStripChar()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()AutoIt SearchAutoIt3 PortableAutoItWinGetTitle()/AutoItWinSetTitle()CodingFileInstallrGeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIGetBkColor()LockFile()PasteBinSciTE JumpSignature CreatorWM_COPYDATAMore Examples...Updated: 11/04/2013


#4 logmein

logmein

    Polymath

  • Active Members
  • PipPipPipPip
  • 214 posts

Posted 17 August 2012 - 08:07 AM

Oh, sorry...

#5 AdmiralAlkex

AdmiralAlkex

    I'm on a boat

  • MVPs
  • 4,490 posts

Posted 17 August 2012 - 08:34 AM

Look in Task Manager, you are most likely running the x86 RegEdit on your first screenshot.

#6 logmein

logmein

    Polymath

  • Active Members
  • PipPipPipPip
  • 214 posts

Posted 17 August 2012 - 10:35 AM

But they are alike. I don't understand. But how to delete or write a registry key in x86 Regedit?

#7 Danyfirex

Danyfirex

    Polymath

  • Active Members
  • PipPipPipPip
  • 239 posts

Posted 17 August 2012 - 01:47 PM

hi you are using bad keys.
if you use 'HKCU64' and 'HKCU' on your program will be appear your key two times. so you would be trying to delete a key who doesn't exist.
else in 86x you repeat two time your key HKLM64 and HKLM. but in 86x does'nt exist 64x keys.

You should Use this.
I think this is the best way.
Select Case @OSArch="X64" ;case OS x64 read this key "HKLM64SoftwareMicrosoftWindowsCurrentVersionRun" "HKLMSoftwareMicrosoftWindowsCurrentVersionRun" "HKCUSoftwareMicrosoftWindowsCurrentVersionRun" Case @OSArch="X86" ;case OS x86 read this key "HKLMSoftwareMicrosoftWindowsCurrentVersionRun" "HKCUSoftwareMicrosoftWindowsCurrentVersionRun" EndSelect EndFunc

Edited by Danyfirex, 17 August 2012 - 02:01 PM.

Posted Image


#8 logmein

logmein

    Polymath

  • Active Members
  • PipPipPipPip
  • 214 posts

Posted 17 August 2012 - 02:46 PM

Still don't work:((

#9 logmein

logmein

    Polymath

  • Active Members
  • PipPipPipPip
  • 214 posts

Posted 17 August 2012 - 02:53 PM

Oh, I solved the problem, firstly, I changed the keys like yours and then add #RequireAdmin at the top of the script:)
Thanks Danyfirex:)

#10 Danyfirex

Danyfirex

    Polymath

  • Active Members
  • PipPipPipPip
  • 239 posts

Posted 17 August 2012 - 02:55 PM

Oh, I solved the problem, firstly, I changed the keys like yours and then add #RequireAdmin at the top of the script:)
Thanks Danyfirex:)



Glad to help you.
regards

Posted Image


#11 AdmiralAlkex

AdmiralAlkex

    I'm on a boat

  • MVPs
  • 4,490 posts

Posted 18 August 2012 - 09:58 PM

But they are alike. I don't understand. But how to delete or write a registry key in x86 Regedit?

That's because WOW redirect x86 apps to another place.

You should read up on the Registry Redirector. There are lots of other interesting things to know about x64 Windows if you follow the links around in that Programming Guide.

Redirected keys are mapped to physical locations under Wow6432Node. For example, HKEY_LOCAL_MACHINESoftware is redirected to HKEY_LOCAL_MACHINESoftwareWow6432Node.







Also tagged with one or more of these keywords: registry, x64, windows 7

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users