Skip to content

Instantly share code, notes, and snippets.

@bburky
Last active April 15, 2019 04:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bburky/618500cbb594d7a5cb0bbf43a0e3df78 to your computer and use it in GitHub Desktop.
Save bburky/618500cbb594d7a5cb0bbf43a0e3df78 to your computer and use it in GitHub Desktop.
regdiff Playnite Extension: Registry snapshot and comparison
Name: regdiff
Author: Blake Burkhart
Version: 1.1
Module: regdiff.ps1
Type: Script
Functions:
# regdiff 1.1
# Discover game settings/save games in the registry.
# This extension takes a snapshot of all registry keys before and after running
# every game. The snapshot and their difference is saved into the game
# installation directory.
# This only works if new keys are created while running the game (i.e. the very
# first time the game is run on your computer.)
# Only registry keys are listed, not names of values.
# Note, this does slow down launching games. You can uncomment two places below
# to only run the diff once per game. Delete the diff file to cause the script
# to rerun.
function SnapshotFileName ($game, $type) {
# Include game id to make files unique even if multiple games are in the same directory
$id = [string]$game.Id
Join-Path $game.InstallDirectory "regdiff-${type}-${id}.txt"
}
function OnGameStarting ($game)
{
$diffFile = SnapshotFileName $game "diff"
if(Test-Path $diffFile -PathType Leaf) {
# Uncomment to skip running if diff already exists
# return
}
$__logger.Info("regdiff OnGameStarting: $($game.Name)")
$global:starting = Get-ChildItem -Path hkcu:\ -Recurse -Name
}
function OnGameStopped ($game, $elapsedSeconds)
{
$diffFile = SnapshotFileName $game "diff"
if(Test-Path $diffFile -PathType Leaf) {
# Uncomment to skip running if diff already exists
# return
}
$__logger.Info("regdiff OnGameStopped: $($game.Name)")
Start-Job -ArgumentList $diffFile, $global:starting {
Param($diffFile, $starting)
$stopped = Get-ChildItem -Path hkcu:\ -Recurse -Name
$diff = Compare-Object -PassThru -CaseSensitive $starting $stopped
# Append the diff to the diff file (or create it if it does not exist)
$diff >> $diffFile
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment