Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Edit the Windows Registry


  • Please log in to reply
1 reply to this topic
bLisTeRinG
  • Members
  • 45 posts
  • Last active: Nov 07 2012 11:15 AM
  • Joined: 15 Nov 2004
If you want to edit the Registry the easiest way is to create a handy shortcut to RegEdit.exe and put it somewhere handy. You can then open the Registry in a window-view, find the information you want and start hacking.

This can be VERY DANGEROUS! Mainly because the logic encoded into the tree of keys with variables attached, is not always obvious. A small change can make the windows installation unfunctional. Worse, one might accidentaly (foolishly) damage the computer peripherals.

That being said, I always go this route because it's so direct. But I still wanted more ease-of-use. I recommend Registry Edit Extention (http://www.regeditx.com) for the history function, and RegShortcut (http://www.mvps.org/...cros/index.html) which is used to open the Registry at the Right-Double-Click(ed) key. I have only Win98SE so anyone who tries this on other flavours should definitely post the results.

My contribution is Tweax. It opens a folder containing .reg files, checks them against the Registry, allows you to 'Merge' them, open them in your editor, or open them in the companion util RegFileEdit and edit/delete the values, and 'Merge' the updates to .reg-files and the Registry. Tweax is for the chosen .regFile(s); RegFileEdit is for each of the .regFile entries. Just Double-Click on the row to open RegFileEdit. Keep them both in the same folder with RegShortcut from Serenity Macros (above). There should be two icons called Tweax.ico and Tweax1.ico I'm not sure how to make them available so use your own for now. The settings are kept in HKLM Software\blistering\Tweax and RegFileEd.

I'm more than open to suggestions!

Tweax
Title=		Tweax v0.1
;;;			bLisTeRinG 2006

#SingleInstance force
deFolder= %1%
FileInstall, Tweax.ico, %A_ScriptDir%\Tweax.ico, 0
FileInstall, Tweax2.ico, %A_ScriptDir%\Tweax2.ico, 0
RegRead, app1, HKLM, Software\bLisTeRinG\Tweax, RegEdit
 If app1=
	app1=%A_WinDir%\RegEdit.exe /s
RegRead, app2, HKLM, Software\bLisTeRinG\Tweax, TxtEdit
 If app2=
	app2=%A_ProgramFiles%\Tools\ePad\EditPad.exe
RegRead, defEd, HKLM, Software\bLisTeRinG\Tweax, DefEdit
 If defEd=app1
	{
	app=%app1%
	edt=Modify
	ebt=Edit
	}
 If defEd=app2
	{
	app=%app2%
	edt=Edit
	ebt=Modify
	}
RegRead, app3, HKLM, Software\bLisTeRinG\Tweax, RegFileEd
 If app3=
	app3=%A_ScriptDir%\RegFileEd.exe
RegRead, dBug, HKLM, Software\bLisTeRinG\Tweax, Confirm 
 If dBug=
	dBug=1
RegRead, regCol, HKLM, Software\bLisTeRinG\Tweax, Colour
 If regCol=
	regCol=green
RegRead, regWPos, HKLM, Software\bLisTeRinG\Tweax, WinPosition
If regWPos=
	regWPos=x11 y10 w318 h261
regPic=%A_ScriptDir%\Tweax2.ico
tog=All

Gui, +Resize +OwnDialogs
Gui, Color, %regCol%
;GuiControl, +backgroundred Cred, Clear
Gui, Add, Button,   x13 y10 w36 h18, More
Gui, Add, Button,   x53 y10 w36 h18, Clear
Gui, Add, Button,   x93 y10 w36 h18 gSelectAllToggle, %tog%
Gui, Add, Button,  x133 y10 w42 h18, %ebt%
Gui, Add, Checkbox,x179 y13 Checked%dBug% gdBug, Confirm?
Gui, Add, Button,  x259 y10 w36 h18 Default, OK
Gui, Add, ListView, x10 y90 r10 vDeClick gDeClick +Checked +Resize, Application|Name|Size|Path
Gui, Add, Picture, x10 y10 gregHelp vregHelp w80 h-1 0x4000000, %regPic%
Gui, -MaximizeBox +ToolWindow +AlwaysOnTop 
Menu, MyContextMenu, Add, Open, ContextOpenFile
Menu, MyContextMenu, Add, Properties, ContextProperties
Menu, MyContextMenu, Add, Clear from List, ContextClearRows
Menu, MyContextMenu, Default, Open

ButtonMore:
Gui, Show, +Hide
StringLen, sLen, deFolder
If deFolder
	{
	IfNotExist, %deFolder%
		{
		MsgBox, 4096, Tweax Error,Folder:`n%deFolder%`nNot Found!
		deFolder=
		}
	}
FileSelectFolder, DirN, %deFolder%,,Choose a Folder containing Registry files (.reg)
If not DirN
	{
	If not DirS
		Goto GuiClose
	Gui, Restore
	Return
	}
DirS=1
SetWorkingDir, DirN
Tooltip, Please wait - Gathering data
Loop, %DirN%\*.reg,,1
	{
	if not A_LoopFileFullPath
		break
	SplitPath, A_LoopFileFullPath,,DName
	StringGetPos, DPos, DName, \, R1
	DPos+=1
	StringTrimleft,  DName, DName, %DPos%
	LV_Add("", DName, A_LoopFileName, A_LoopFileSize, A_LoopFileFullPath)
	LV_ModifyCol()
	LV_ModifyCol(3, "Integer")
	LV_ModifyCol(4, "120")
	}
LV_ModifyCol(1, "Sort")
Gui, Restore
Gui, Show, %regWPos%, %A_Space%%A_Space%%edt% regFiles/Registry.
Tooltip, 
Return

GuiEscape:
GuiClose:
WinGetPos, regWx, regWy, regWw, regWh, A
regWw -= 12
regWh -= 34
regWpos=x%regWx% y%regWy% w%regWw% h%regWh%
RegWrite, REG_SZ, HKLM, Software\bLisTeRinG\Tweax, WinPosition, %regWPos%
ExitApp

DeClick:
If A_GuiEvent = DoubleClick
	{
	regRow := LV_GetNext(0, "F")
	If not regRow
		Return
	LV_GetText(reg4, regRow, 4)
	Run, %app3% "%reg4%",, UseErrorLevel
;	MsgBox, 4096, Tweax, %app3% "%reg4%"
	}
Return

ButtonOK:
Gui, -AlwaysOnTop
RowNumber=0
Job=
Loop
	{
	RowNumber := LV_GetNext(RowNumber,"C")
	If not RowNumber
		Break
	LV_GetText(jb, RowNumber,4)
	Job=%Job%"%jb%"`n
	}
If dBug = 1
	{
	Gui, Show, +Hide
	MsgBox, 4100, %edt%?, You have chosen to %edt%:`n%Job%
	Gui, Restore
	}
IfMsgBox, No
	Return
Loop, parse, job, `n
	{
	StringLen, SLen, A_LoopField
	If SLen < 4
		Break
	RunWait %app% %A_LoopField%
	Tooltip, %app% %A_LoopField% 
	}
Gui, +AlwaysOnTop
Tooltip,
Return

ButtonClear:
LV_Delete()
Return

ButtonModify:
ButtonEdit:
If defEd=app1
	{
	app=%app2%
	defEd=app2
	ebt=Modify
	edt=Edit
	}
	Else
	{
	app=%app1%
	defEd=app1
	ebt=Edit
	edt=Modify
	}
Gui, Show,, %A_Space%%A_Space%%edt%
ControlSetText, %edt%, %ebt%,
RegWrite, REG_SZ, HKLM, Software\bLisTeRinG\Tweax, DefEdit, %defEd%
Return

regHelp:
Gui, Show, +Hide
MsgBox, 4096, Help, How would I know?
Gui, Restore
Return

SelectAllToggle:
If tog = All
	{
	tog=None
	LV_Modify(0, "Check")
	ControlSetText, None, %Tog%,
	}
	Else
	{
	tog=All
	LV_Modify(0, "-Check")
	ControlSetText, All, %Tog%,
	}
Return

dBug:
If dBug = 1
	{
	dBug=0
	GuiControl,, dBug, 0
	}
	Else
	{
	dBug=1
	GuiControl,, dBug, 1
	}
RegWrite, REG_SZ, HKLM, Software\bLisTeRinG\Tweax, confirm, %dBug%
Return

GuiSize:
If A_EventInfo = 1
	Return
GuiControl, Move, DeClick, % "W" . (A_GuiWidth - 20) . " H" . (A_GuiHeight - 100)
Return

GuiContextMenu:  ; Launched in response to a right-click or press of the Apps key.
if A_GuiControl <> DeClick  ; Display the menu only for clicks inside the ListView.
	return
; Show the menu at the provided coordinates, A_GuiX and A_GuiY.  These should be used
; because they provide correct coordinates even if the user pressed the Apps key:
Menu, MyContextMenu, Show, %A_GuiX%, %A_GuiY%
Return

ContextOpenFile:  ; The user selected "Open" in the context menu.
ContextProperties:  ; The user selected "Properties" in the context menu.
; For simplicitly, operate upon only the focused row rather than all selected rows:
FocusedRowNumber := LV_GetNext(0, "F")  ; Find the focused row.
If not FocusedRowNumber  ; No row is focused.
	Return
LV_GetText(FName, FocusedRowNumber, 4)
IfInString A_ThisMenuItem, Open  ; User selected "Open" from the context menu.
	Run %FName%,, UseErrorLevel
else  ; User selected "Properties" from the context menu.
	Run Properties "%FName%",, UseErrorLevel
If ErrorLevel
	MsgBox, 4096, Tweax Error, %ErrorLevel%`nCould``nt`n"%FName%"
Return

ContextClearRows:  ; The user selected "Clear" in the context menu.
RowNumber = 0  ; This causes the first iteration to start the search at the top.
Loop
{
	; Since deleting a row reduces the RowNumber of all other rows beneath it,
	; subtract 1 so that the search includes the same row number that was previously
	; found (in case adjacent rows are selected):
	RowNumber := LV_GetNext(RowNumber - 1)
	If not RowNumber  ; The above returned zero, so there are no more selected rows.
		break
	LV_Delete(RowNumber)  ; Clear the row from the List.
}
Return

RegFileEd
Title=		Registry File Editor v0.2
;;;			bLisTeRinG 2006

#SingleInstance Off
regFile=%1%
SplitPath, regFile, regFName 
RegRead, app1, HKLM, Software\bLisTeRinG\RegFileEd, HelperApp1
If app1=
	app1=%A_ScriptDir%\RegShortcut.exe
RegRead, regMT, HKLM, Software\bLisTeRinG\RegFileEd, EmptyKeys
If regMT=
	regMT=0
RegRead, chkConf, HKLM, Software\bLisTeRinG\RegFileEd, Confirm
If chkConf=
	chkConf=1
RegRead, regCol, HKLM, Software\bLisTeRinG\RegFileEd, Colour
If regCol=
	regCol=green
RegRead, regWPos, HKLM, Software\bLisTeRinG\RegFileEd, WinPosition
If regWPos=
	regWPos=x60 y180 w600 h200
Loop, Parse, regWPos, %A_Space%
	{
	y = %A_LoopField%
	StringTrimLeft, y, y, 1
	If A_Index < 3
		{
		y += 20
		x%A_Index% = %y%
		}
		Else
		{
		x%A_Index% = %y%
		}
	}
regXpos=x%x1% y%x2% w%x3% h%x4% 
;msgbox, 4096,,regXpos:%regXpos%`n%x1%`n%x2%`n%x3%`n%x4%
RegWrite, REG_SZ, HKLM, Software\bLisTeRinG\RegFileEd, WinPosition, %regXpos%
;Yes yes add some resolution checking with A_ScreenWidth A_ScreenHeightregXpos=
;; SysGet Mon, MonitorWorkArea
;; MsgBox %MonLeft% - %MonTop% - %MonRight% - %MonBottom%x=
y=
x1=
x2=
x3=
x4=

regExp=Double-Click to copy the value here for editing.
regRow=1
regPic=%A_ScriptDir%\Tweax2.ico

Gui, +AlwaysOnTop +Resize +OwnDialogs
Gui, Color, %regCol%
Gui, Add, Edit, y7 -ReadOnly vregTxt, %regExp%
Gui, Add, Button, y7 gregText, Done
Gui, Add, Button, y7 gregSfile, Save to File
Gui, Add, Button, y7 gregSreg, Save to Registry
Gui, Add, Button, y7 gregZfile, Delete from File
Gui, Add, Button, y7 gregNfile, New
Gui, Add, Checkbox, xm y36 -Checked%regMT% gregMT vregMT, Show Empty/Default keys? (and Refresh List)
Gui, Add, Checkbox, x260 y36 -Checked%chkConf% gchkConf vchkConf, Confirm?
Gui, Add, ListView,  x10 y80 r4 w40 h10 vdeClick gdeClick, Root|Sub|Key|FileValue|RegistryValue
Gui, Add, Picture, x500 y0 gregHelp vregHelp w80 h-1 0x4000000, %regPic%
Gui, Add, Button, Hidden Default, Default
GuiControl, Focus, deClick
Gosub Top
Return

Top:
Loop, Read, %regFile%
	{
	IfInString, A_LoopReadLine, [
		{
		StringGetPos, regPos, A_LoopReadLine, ], L1
		regPos:=(regPos-1)
		StringMid, regSect, A_LoopReadLine, 2, %regPos%
		IfInString, A_LoopReadLine, \
			{
			StringGetPos, regPL, regSect, \, L1
			StringMid, regRoot, regSect, 1, %regPL%
			StringGetPos, regPR, regSect, \, R1
			If %regPL% = %regPR%
				{
				regPL:=(regPL+2)
				StringMid, regSub, regSect, %regPL%, %regPos%
				}
				Else
				{
				regPR:=(regPR-2)
				regPL:=(regPL+2)
				StringMid, regSub, regSect, %regPL%, %regPR%
				}
			}
		If regMT = 1
			{
			RegRead, regReg, %regRoot%, %regSub%
			If regReg=
				{
				regReg=<Empty>
				}
			LV_Add("", regRoot,regSub,"","",regReg)
			}
		}
	IfInString, A_LoopReadLine, =
		{
		StringSplit, regVal, A_LoopReadLine, =
		If regVal1 = @
			{
			RegRead, regReg, %regRoot%, %regSub%
			}
			Else
			{
			qOff=%regVal1%
			Gosub QuoteOff
			regVal1=%qOff%
			RegRead, regReg, %regRoot%, %regSub%, %regVal1%
			}
		If regReg=
			regReg=<Not in Registry>
		If regVal2=
			{
			regVal2=<Empty>
			}
			Else
			{
			qOff=%regVal2%
			Gosub QuoteOff
			regVal2=%qOff%
			}
		LV_Add("",regRoot,regSub,regVal1,regVal2,regReg)
		regReg=
		regVal2=
		regVal1=
		regVal=
		}
	regPL=
	regPR=
	regReg=
	}
LV_ModifyCol()
LV_ModifyCol(2, Right)
Gui, Show, %regWPos%,%regFName%  >>>  %Title%
LV_Modify(regRow, "Select")
LV_Modify(regRow, "Focus")
Return

chkConf:
If chkConf = 1
	{
	chkConf=0
	GuiControl,, chkConf, 0
	}
	Else
	{
	chkConf=1
	GuiControl,, chkConf, 1
	}
RegWrite, REG_SZ, HKLM, Software\bLisTeRinG\RegFileEd, Confirm, %chkConf%
Return

QuoteOff:
StringGetPos, quoL, qOff,`", L
If quoL=0
	{
	StringGetPos, quoR, qOff,`", R
		{
		StringLen, sLen, qOff
		sLen-=1
		If quoR=%sLen%
			{
			StringTrimRight, qOff, qOff, 1
			StringTrimLeft, qOff, qOff, 1
			}
		}
	}
Return

GuiClose:
GuiEscape:
WinGetPos, regW1, regW2, regW3, regW4, A
regW3 -= 12
regW4 -= 32
regWpos=x%regW1% y%regW2% w%regW3% h%regW4%
RegWrite, REG_SZ, HKLM, Software\bLisTeRinG\RegFileEd, WinPosition, %regWPos%
ExitApp

GuiSize:
If A_EventInfo = 1
	Return
GuiControl, Move, deClick, % "W" . (A_GuiWidth - 20) . " H" . (A_GuiHeight - 90)
Return

regHelp:
Gui, Show, +Hide
MsgBox, 4096, Help, How would I know?
Gui, Restore
Return

regMT:
If regMT = 0
	{
	regMT=1
	GuiControl,, regMT, 1
	}
	Else
	{
	regMT=0
	GuiControl,, regMT, 0
	}
LV_Delete()
RegWrite, REG_SZ, HKLM, Software\bLisTeRinG\RegFileEd, EmptyKeys, %regMT%
GoSub Top 
Return

ButtonDone:
regText:
regRow := LV_GetNext(0, "F")
If not regRow
	Return
GuiControlGet, regRw4,, regTxt
;MsgBox, 4096, RegFileEd Row data, 1:%regRw1%`n2:%regRw2%`n3:%regRw3%`n4:%regRw4%`nold:%regExp%
LV_Modify(regRow, "Col4", regRw4) 
GuiControl, Focus, deClick
Return

ButtonDefault:
deClick:
;MsgBox, 4096, RegFileEd Buttons, ButtonDefault`nA_GuiEvent:%A_GuiEvent%`nA_EventInfo:%A_EventInfo%
regRow := LV_GetNext(0, "F")
If not regRow
	Return
If A_GuiEvent = Normal
	{
	If A_EventInfo
		{
		Goto ButtonDone
		}
	}
If A_GuiEvent = R
	{
	LV_GetText(de1, A_EventInfo,1)
	LV_GetText(de2, A_EventInfo,2)
	Run, %app1% %de1%\%de2%\
	Return
	}
LV_GetText(regExp, regRow, 4)
GuiControl,, regTxt, %regExp%
GuiControl, Focus, regTxt
;GuiControl, Select, regTxt
Return

regNfile:

Return

regZfile:
Gosub regLine
Gosub regFileLine
If chkConf = 1
	MsgBox, 4100, Delete a regFile key., Delete the regFile Key?:`n`n%reg1%`n`\%reg2%`n`n%reg3%=%reg4%
	IfMsgBox, No
		Return
Tooltip, Deleting %reg3% from %reg1%`\%reg2%
IniDelete, %regFile%, %reg1%`\%reg2%, %reg3%
LV_Delete()
GoSub Top 
Tooltip,
Return

regSfile:
Gosub regLine
Gosub regFileLine
If chkConf = 1
	MsgBox, 4100, Update a regFile value., Apply to %regFile%?:`n`n%reg1%`\%reg2%`n%reg3%=%reg4%
	IfMsgBox, No
		Return
Tooltip, Saving %regFile% ... %reg3%=%reg4%
IniWrite, %reg4%, %regFile%, %reg1%`\%reg2%, %reg3%
LV_Delete()
GoSub Top 
Tooltip,
Return

regSreg:
Gosub regLine
If chkConf = 1
	MsgBox, 4100, Update a Registry Value., Apply to the Registry?:`n`n%reg1%`\%reg2%`n%reg3%=%reg4% 
	IfMsgBox, No
		Return
If reg3 = @
	{
	reg3=
	}
Tooltip, Saving to Registry ... %reg3%=%reg4%
RegWrite, REG_SZ, %reg1%, %reg2%, %reg3%, %reg4%
LV_Delete()
GoSub Top 
Tooltip,
Return

regLine:
regRow := LV_GetNext(0, "F")
If not regRow
	Return
LV_GetText(reg1, regRow, 1)
LV_GetText(reg2, regRow, 2)
LV_GetText(reg3, regRow, 3)
LV_GetText(reg4, regRow, 4)
Return

regFileLine:
If reg3 = @
	{
	Goto regSfile1
	}
reg3=`"%reg3%`"
regSfile1:
If reg4 =
	{
	Goto regSfile2
	}
reg4=`"%reg4%`"
regSfile2:
Return

gq.

bLisTeRinG
  • Members
  • 45 posts
  • Last active: Nov 07 2012 11:15 AM
  • Joined: 15 Nov 2004
Give it a go!

Surely someone sets up stuff in the registry?
A previously messy bunch of .reg files can be easier to use.

I'm using it (and tuning it) and it saves heaps of time.

gq