Last active
April 15, 2019 04:34
-
-
Save bburky/618500cbb594d7a5cb0bbf43a0e3df78 to your computer and use it in GitHub Desktop.
regdiff Playnite Extension: Registry snapshot and comparison
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Name: regdiff | |
Author: Blake Burkhart | |
Version: 1.1 | |
Module: regdiff.ps1 | |
Type: Script | |
Functions: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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