PowerShellRuntime methods for running uninstall scripts

This commit is contained in:
Pat Hartl 2023-01-15 01:28:05 -06:00
parent b689abb8bc
commit 352d2a13e6

View file

@ -12,7 +12,7 @@ namespace LANCommander.PlaynitePlugin
{
internal class PowerShellRuntime
{
public void RunScript(string script, Dictionary<string, object> parameters)
public void RunScript(string script)
{
var process = new Process();
process.StartInfo.FileName = "powershell.exe";
@ -25,22 +25,22 @@ namespace LANCommander.PlaynitePlugin
public void RunInstallScript(Game game)
{
var defaultParameters = new Dictionary<string, object>()
{
{ "InstallDir", game.InstallDirectory },
{ "Title", game.Name },
{ "Description", game.Description },
{ "GameId", game.GameId }
};
var scriptPath = Path.Combine(game.InstallDirectory, "_install.ps1");
if (!File.Exists(scriptPath))
throw new FileNotFoundException(scriptPath);
var scriptContents = File.ReadAllText(scriptPath);
RunScript(scriptPath);
}
RunScript(scriptPath, defaultParameters);
public void RunUninstallScript(Game game)
{
var scriptPath = Path.Combine(game.InstallDirectory, "_uninstall.ps1");
if (!File.Exists(scriptPath))
throw new FileNotFoundException(scriptPath);
RunScript(scriptPath);
}
}
}