TomXIII wrote:
Hi everybody!
I'm trying to code a fully portable (discret) version of AutoHotkey at every levels I can:
-Regedit (not so easy!)
<snip>
I use RegShot to quickly find modifications but not very efficient!
If some people can help me?!
Take a look at JauntePE. It's an alpha release for making apps portable. Now alpha means it's even less ready than the typical beta release, but as I recall, the examples included making Windows regedit portable. Maybe that could be of use to you while you until your AHK script is ready.
link:
http://www.portablefreeware.com/?id=1452
For RegShot v1.8.2, I use it to take snapshot before and after installing apps. My ini settings:
Code:
[Setup]
Flag=3
ExtDir=C:\WINDOWS;C:\Documents and Settings;C:\Program Files\Common Files;C:\Program Files\InstallShield Installation Information;
OutDir=Z:\_Backups\RegShots
UseLongRegHead=0
[SkipRegKey]
0=
1=
2=
3=
[SkipDir]
0=Rising
1=OnlineArmor
2=Recent
3=
My SkipDirs are just my antivirus (Rising) and firewall (OnlineArmor). I removed most of the SkipRegKeys and SkipDirs because I now use AHK to clean up my RegShot output. Here's my RegShot Cleaning script (uses Sean's ShellFolder at one point). It may be of use to you for cleaning up the noise from your own RegShot logs, though please note that my is still in development and has bugs - for example, I need to get it to ignore spaces when comparing reg values or otherwise make the comparison format uniform between data AHK retrieves and what's in the RegShot log.
Code:
#SingleInstance, Force
SetFormat, IntegerFast, Hex
AutoTrim, Off
#IfWinActive ahk_class CabinetWClass
APPSKEY & LBUTTON::
SF := ShellFolder()
StringSplit,SFV, SF, `r`n
filename:= RegExReplace( SFV2, "Focus: " )
StringTrimRight, filename, filename, 4
SF:=SFV:=
FileRead, RegShot, %filename%.txt
Sleep, 500
matcher := 1, section := ""
If not ErrorLevel ; Successfully loaded.
{ Loop ;remove empty lines
{ StringReplace,RegShot,RegShot, `r`n`r`n, `r`n, UseErrorLevel
if ErrorLevel = 0 ; No more replacements needed.
break
}
Sleep, 100 ;split file into sections
Loop, parse, RegShot, `n, `r, %A_Space%%A_Tab%
{ ;Add entries to remove below
If A_LoopField Contains ntuser.dat
,Mozilla\Firefox\Profiles\k2qzu7cz.default
,Cookies\index.dat
,%A_AppData%\Microsoft\HTML Help\hh.dat
,%A_AppData%\Scooter Software\Beyond Compare 3
,Local Settings\Application Data\Bill2_Software
,Local Settings\Application Data\Microsoft\Windows\UsrClass.dat.LOG
,Local Settings\Application Data\Mozilla\Firefox\Profiles\k2qzu7cz.default
,Local Settings\Application Data\Search and Replace\EXPLORER.SRS
,Local Settings\History\History.IE5
,Local Settings\Temporary Internet Files\Content.IE5\desktop.ini
,Local Settings\Temporary Internet Files\Content.IE5\index.dat
,Local Settings\Temporary Internet Files\desktop.ini
,%A_WinDir%\Debug\PASSWD.LOG
,%A_WinDir%\erdnt
,%A_WinDir%\Prefetch
,%A_WinDir%\Rav.ini
,%A_WinDir%\Sandboxie.ini
,%A_WinDir%\Security\edb.chk
,%A_WinDir%\Security\edb.log
,%A_WinDir%\system32\CatRoot2
,%A_WinDir%\system32\config\AppEvent.Evt
,%A_WinDir%\system32\config\default
,%A_WinDir%\system32\config\SecEvent.Evt
,%A_WinDir%\system32\config\sam
,%A_WinDir%\system32\config\security
,%A_WinDir%\system32\config\software
,%A_WinDir%\system32\config\SysEvent.Evt
,%A_WinDir%\system32\config\system
,%A_WinDir%\system32\wbem
,%A_WinDir%\Tasks\Clean System Memory.job
,%A_WinDir%\wiadebug.log
,%A_WinDir%\wiaservc.log
,%A_WinDir%\WindowsUpdate.log
,HKLM\HARDWARE\RESOURCEMAP
,HKLM\SOFTWARE\Microsoft\Cryptography\RNG
,HKLM\SOFTWARE\Microsoft\EventSystem
,HKLM\SOFTWARE\Microsoft\SchedulingAgent
,HKLM\SOFTWARE\Microsoft\UPnP Device Host
,HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State
,HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData
,HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RecentDocs
,HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Prefetcher
,HKLM\SOFTWARE\Microsoft\WZCSVC
,HKLM\SYSTEM\ControlSet001\Control\Session Manager
,HKLM\SYSTEM\ControlSet001\Enum
,HKLM\SYSTEM\ControlSet002\Control\Session Manager
,HKLM\SYSTEM\ControlSet002\Enum
,HKLM\SYSTEM\ControlSet003\Control\Session Manager
,HKLM\SYSTEM\ControlSet003\Enum
,HKLM\SYSTEM\CurrentControlSet\Control\DeviceClasses
,HKLM\SYSTEM\CurrentControlSet\Control\ServiceCurrent
,HKLM\SYSTEM\CurrentControlSet\Control\Session Manager
,HKLM\SYSTEM\CurrentControlSet\Enum
,SessionInformation\ProgramCount
,Software\LopeSoft\FileMenu Tools
,Software\Microsoft\Windows\CurrentVersion\Explorer\CLSID\{645FF040-5081-101B-9F08-00AA002F954E}\DefaultIcon
,Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32
,Software\Microsoft\Windows\CurrentVersion\Explorer\Discardable\PostSetup\Component Categories
,Software\Microsoft\Windows\CurrentVersion\Explorer\Discardable\PostSetup\ShellNew
,Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts
,Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrder
,Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs
,Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU
,Software\Microsoft\Windows\CurrentVersion\Explorer\StartPage
,Software\Microsoft\Windows\CurrentVersion\Explorer\StreamMRU
,Software\Microsoft\Windows\CurrentVersion\Explorer\Streams
,Software\Microsoft\Windows\CurrentVersion\Explorer\TrayNotify
,Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist
,Software\Microsoft\Windows\CurrentVersion\Ext\Stats
,Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections
,Software\Microsoft\Windows\CurrentVersion\Shell Extensions
,Software\Microsoft\Windows\Shell\Bags
,Software\Microsoft\Windows\ShellNoRoam\BagMRU
,Software\Microsoft\Windows\ShellNoRoam\Bags
,Software\Microsoft\Windows\ShellNoRoam\MUICache
,Software\WinRAR
Continue
Else If A_LoopField = ----------------------------------
matcher*= -1
Else If matcher = -1
{ colon:= InStr(A_LoopField, ":" ) - 1
section:= SubStr(A_LoopField, 1, colon)
StringReplace, section, section, [attributes?]%A_Space%
}
Else
{ If (section = "Folders added") && FileExist(A_LoopField)
FileAppend, %A_LoopField%`n, %filename%_fAdded.txt
If (section = "Files added") && FileExist(A_LoopField)
FileAppend, %A_LoopField%`n, %filename%_fAdded.txt
If (section = "Files modified") && FileExist(A_LoopField)
FileAppend, %A_LoopField%%A_Space%(modified)`n, %filename%_fAdded.txt
If (section = "Keys added")
{ keycount:= 0, slash1:= InStr(A_LoopField, "" )
root:= SubStr(A_LoopField, 1, slash1-1), sub:= SubStr(A_LoopField, slash1+1)
Loop %root%, %sub%, 1, 1 ; checks if key exists
keycount++
If (keycount > 0)
FileAppend, %root%\%sub%`n, %filename%_rAdded.txt
}
If (section = "Values added")
{ slash1:= InStr(A_LoopField, "" ), colon1:= InStr(A_LoopField, ":" )
temp:= SubStr(A_LoopField, 1, colon1), slash2:= InStr(temp,"",false,0)
StringLeft, root, A_LoopField, % slash1-1
StringMid, sub, A_LoopField, slash1+1, slash2-slash1-1
StringMid, vname, A_LoopField, slash2+1, colon1-slash2-1
StringRight, val, A_LoopField, % StrLen(A_LoopField)-colon1-1
If InStr(val, """", false, 1) = 1 && InStr(val, """", false, 0) = StrLen(val)
StringMid, val, val, 2, % StrLen(val)-2 ;remove excess "
RegRead, valNow, %root%, %sub%, %vname%
If ErrorLevel != 1 ;if no problem
{ If ( val = valNow )
FileAppend, %root%\%sub%\%vname%:%A_Space%%val%`n, %filename%_rAdded.txt
else
FileAppend, %root%\%sub%\%vname%:%A_Space%%val%%A_Space%(old)`n%root%\%sub%\%vname%:%A_Space%%valNow%%A_Space%(new)`n, %filename%_rAdded.txt
}
}
If (section = "Values modified")
{ slash1:= InStr(A_LoopField, "" ), colon1:= InStr(A_LoopField, ":" )
temp:= SubStr(A_LoopField, 1, colon1), slash2:= InStr(temp,"",false,0)
StringReplace, section, section, [attributes?]%A_Space%
StringLeft, root, A_LoopField, % slash1-1
StringMid, sub, A_LoopField, slash1+1, % slash2-slash1-1
StringMid, vname, A_LoopField, slash2+1, % colon1-slash2-1
StringRight, val, A_LoopField, % StrLen(A_LoopField)-colon1-1
If InStr(val, """", false, 1) = 1 && InStr(val, """", false, 0) = StrLen(val)
StringMid, val, val, 2, % StrLen(val)-2 ;remove excess "
RegRead, valNow, %root%, %sub%, %vname%
If ErrorLevel != 1 ;if no problem
{ If (val = valNow)
FileAppend, %root%\%sub%\%vname%:%A_Space%%val%%A_Space%(modified)`n, %filename%_rAdded.txt
else
FileAppend, %root%\%sub%\%vname%:%A_Space%%val%%A_Space%(mod_old)`n%root%\%sub%\%vname%:%A_Space%%valNow%%A_Space%(mod_new)`n, %filename%_rAdded.txt
}
}
}
}
}
Sleep, 100
If FileExist(filename . "_fAdded.txt")
{
FileRead, list, %filename%_fAdded.txt
list := RegExReplace(list, "(.*?);(\d+)(\n|$)", "$2;$1$3") ; swap number with path
Sort, list ; sort list in reverse numeric order
list := RegExReplace(list, "(\d+);(.*?)(\n|$)", "$2;$1$3") ; swap back
FileDelete, %filename%_fAdded.txt
FileAppend, %list%, %filename%_fAdded.txt
}
Sleep, 100
If FileExist(filename . "_rAdded.txt")
{
FileRead, list, %filename%_rAdded.txt
list := RegExReplace(list, "(.*?);(\d+)(\n|$)", "$2;$1$3") ; swap number with path
Sort, list ; sort list in reverse numeric order
list := RegExReplace(list, "(\d+);(.*?)(\n|$)", "$2;$1$3") ; swap back
FileDelete, %filename%_rAdded.txt
FileAppend, %list%, %filename%_rAdded.txt
list = ; Free the memory.
}
SoundPlay *-1
TrayTip, RegShot cleaning finished.,File log saved to %filename%_fAdded.txt`nRegistry log saved to %filename%_rAdded.txt, 15, 1
;return
/*
"modified" files were present at the installation, but modified at the time.
reg values without label were added. if the value had changed since it was
recorded in the install log, the "old" version contains logged value and
the "new" value contains the current value.
reg entries "modified" weren't added and haven't changed since install log.
"mod_old" is the old "modified" value of a reg entry.
"mod_new" is the current value of entry that had been modified.
*/
SetFormat, IntegerFast, Decimal
Sleep, 1000
MsgBox, 4,, Press Yes to TreeView Files/Folders, No for Registry Keys/Values.
IfMsgBox Yes
logfile:= filename . "_fAdded.txt"
else
logfile:= filename . "_rAdded.txt"
If !FileExist(logfile)
{
MsgBox, No %filename% entries found:`nEither they've already been uninstalled and removed, or an error occurred.
}
TreeViewWidth := 500
Gui +Resize
Gui, Add, TreeView,r30 w%TreeViewWidth%
AddBranchesToTree(logfile) ; list needs to be sorted
Gui, Show ; Show the window and its TreeView.
Return
GuiEscape:
GuiClose: ; Exit the script when the user closes the TreeView's GUI window.
ExitApp
AddBranchesToTree(filelist)
{
level = 0
parent0 = 0
loop, read, % filelist
{
if a_loopreadline =
continue
stringsplit, parts, a_loopreadline, \ ; drive + folders ( + file)
if level = 0 ; first record, insert all parts
{
gosub build_tree
continue
}
ifinstring, a_loopreadline, %prev_file% ; sub folders or files
{
gosub build_tree
continue
}
; other drive or folder
line := a_loopreadline
if (parts0 > level) ; ignore parts > level
loop, % parts0 - level - 1
StringLeft, line, line, % InStr(line,"",false,0)
else
level := parts0 ; set level to no of parts
loop, % level
{
StringLeft, line, line, % InStr(line,"",false,0)-1
level--
if level = 0 ; other drive
{
prev_file =
bs =
}
else ; find corresponding level
{
prev_file := file%level%
ifnotinstring, line, %prev_file%
continue
if level = 0
level++
}
gosub build_tree
break
}
}
return
build_tree:
loop, % parts0 - level
{
prev_parent = parent%level%
level++
parent%level% := tv_add(parts%level%, %prev_parent%, "expand")
if level <> 1
bs = \
file%level% := prev_file bs parts%level%
prev_file := file%level%
}
return
}