Only execute scripts if they exists on the disk
parent
986fb87db1
commit
a9f3b7a39d
|
@ -7,6 +7,7 @@ using Playnite.SDK.Models;
|
|||
using Playnite.SDK.Plugins;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace LANCommander.PlaynitePlugin
|
||||
|
@ -139,51 +140,72 @@ namespace LANCommander.PlaynitePlugin
|
|||
private int RunInstallScript(string installDirectory)
|
||||
{
|
||||
var manifest = ManifestHelper.Read(installDirectory);
|
||||
var script = new PowerShellScript();
|
||||
var path = ScriptHelper.GetScriptFilePath(installDirectory, SDK.Enums.ScriptType.Install);
|
||||
|
||||
script.AddVariable("InstallDirectory", installDirectory);
|
||||
script.AddVariable("GameManifest", manifest);
|
||||
script.AddVariable("DefaultInstallDirectory", Plugin.Settings.InstallDirectory);
|
||||
script.AddVariable("ServerAddress", Plugin.Settings.ServerAddress);
|
||||
if (File.Exists(path))
|
||||
{
|
||||
var script = new PowerShellScript();
|
||||
|
||||
script.UseFile(ScriptHelper.GetScriptFilePath(installDirectory, SDK.Enums.ScriptType.Install));
|
||||
script.AddVariable("InstallDirectory", installDirectory);
|
||||
script.AddVariable("GameManifest", manifest);
|
||||
script.AddVariable("DefaultInstallDirectory", Plugin.Settings.InstallDirectory);
|
||||
script.AddVariable("ServerAddress", Plugin.Settings.ServerAddress);
|
||||
|
||||
return script.Execute();
|
||||
script.UseFile(ScriptHelper.GetScriptFilePath(installDirectory, SDK.Enums.ScriptType.Install));
|
||||
|
||||
return script.Execute();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int RunNameChangeScript(string installDirectory)
|
||||
{
|
||||
var manifest = ManifestHelper.Read(installDirectory);
|
||||
var script = new PowerShellScript();
|
||||
var path = ScriptHelper.GetScriptFilePath(installDirectory, SDK.Enums.ScriptType.NameChange);
|
||||
|
||||
script.AddVariable("InstallDirectory", installDirectory);
|
||||
script.AddVariable("GameManifest", manifest);
|
||||
script.AddVariable("DefaultInstallDirectory", Plugin.Settings.InstallDirectory);
|
||||
script.AddVariable("ServerAddress", Plugin.Settings.ServerAddress);
|
||||
script.AddVariable("OldPlayerAlias", "");
|
||||
script.AddVariable("NewPlayerAlias", Plugin.Settings.PlayerName);
|
||||
if (File.Exists(path))
|
||||
{
|
||||
var script = new PowerShellScript();
|
||||
|
||||
script.UseFile(ScriptHelper.GetScriptFilePath(installDirectory, SDK.Enums.ScriptType.NameChange));
|
||||
script.AddVariable("InstallDirectory", installDirectory);
|
||||
script.AddVariable("GameManifest", manifest);
|
||||
script.AddVariable("DefaultInstallDirectory", Plugin.Settings.InstallDirectory);
|
||||
script.AddVariable("ServerAddress", Plugin.Settings.ServerAddress);
|
||||
script.AddVariable("OldPlayerAlias", "");
|
||||
script.AddVariable("NewPlayerAlias", Plugin.Settings.PlayerName);
|
||||
|
||||
return script.Execute();
|
||||
script.UseFile(path);
|
||||
|
||||
return script.Execute();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int RunKeyChangeScript(string installDirectory)
|
||||
{
|
||||
var manifest = ManifestHelper.Read(installDirectory);
|
||||
var script = new PowerShellScript();
|
||||
var path = ScriptHelper.GetScriptFilePath(installDirectory, SDK.Enums.ScriptType.KeyChange);
|
||||
|
||||
var key = Plugin.LANCommanderClient.GetAllocatedKey(manifest.Id);
|
||||
if (File.Exists(path))
|
||||
{
|
||||
var script = new PowerShellScript();
|
||||
|
||||
script.AddVariable("InstallDirectory", installDirectory);
|
||||
script.AddVariable("GameManifest", manifest);
|
||||
script.AddVariable("DefaultInstallDirectory", Plugin.Settings.InstallDirectory);
|
||||
script.AddVariable("ServerAddress", Plugin.Settings.ServerAddress);
|
||||
script.AddVariable("AllocatedKey", key);
|
||||
var key = Plugin.LANCommanderClient.GetAllocatedKey(manifest.Id);
|
||||
|
||||
script.UseFile(ScriptHelper.GetScriptFilePath(installDirectory, SDK.Enums.ScriptType.KeyChange));
|
||||
script.AddVariable("InstallDirectory", installDirectory);
|
||||
script.AddVariable("GameManifest", manifest);
|
||||
script.AddVariable("DefaultInstallDirectory", Plugin.Settings.InstallDirectory);
|
||||
script.AddVariable("ServerAddress", Plugin.Settings.ServerAddress);
|
||||
script.AddVariable("AllocatedKey", key);
|
||||
|
||||
return script.Execute();
|
||||
script.UseFile(path);
|
||||
|
||||
return script.Execute();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -538,52 +538,73 @@ namespace LANCommander.PlaynitePlugin
|
|||
private int RunInstallScript(string installDirectory)
|
||||
{
|
||||
var manifest = ManifestHelper.Read(installDirectory);
|
||||
var script = new PowerShellScript();
|
||||
var path = ScriptHelper.GetScriptFilePath(installDirectory, SDK.Enums.ScriptType.Install);
|
||||
|
||||
script.AddVariable("InstallDirectory", installDirectory);
|
||||
script.AddVariable("GameManifest", manifest);
|
||||
script.AddVariable("DefaultInstallDirectory", Settings.InstallDirectory);
|
||||
script.AddVariable("ServerAddress", Settings.ServerAddress);
|
||||
if (File.Exists(path))
|
||||
{
|
||||
var script = new PowerShellScript();
|
||||
|
||||
script.UseFile(ScriptHelper.GetScriptFilePath(installDirectory, SDK.Enums.ScriptType.Install));
|
||||
script.AddVariable("InstallDirectory", installDirectory);
|
||||
script.AddVariable("GameManifest", manifest);
|
||||
script.AddVariable("DefaultInstallDirectory", Settings.InstallDirectory);
|
||||
script.AddVariable("ServerAddress", Settings.ServerAddress);
|
||||
|
||||
return script.Execute();
|
||||
script.UseFile(path);
|
||||
|
||||
return script.Execute();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int RunNameChangeScript(string installDirectory, string oldPlayerAlias, string newPlayerAlias)
|
||||
{
|
||||
var manifest = ManifestHelper.Read(installDirectory);
|
||||
var script = new PowerShellScript();
|
||||
var path = ScriptHelper.GetScriptFilePath(installDirectory, SDK.Enums.ScriptType.NameChange);
|
||||
|
||||
script.AddVariable("InstallDirectory", installDirectory);
|
||||
script.AddVariable("GameManifest", manifest);
|
||||
script.AddVariable("DefaultInstallDirectory", Settings.InstallDirectory);
|
||||
script.AddVariable("ServerAddress", Settings.ServerAddress);
|
||||
script.AddVariable("OldPlayerAlias", oldPlayerAlias);
|
||||
script.AddVariable("NewPlayerAlias", newPlayerAlias);
|
||||
if (File.Exists(path))
|
||||
{
|
||||
var script = new PowerShellScript();
|
||||
|
||||
script.UseFile(ScriptHelper.GetScriptFilePath(installDirectory, SDK.Enums.ScriptType.NameChange));
|
||||
script.AddVariable("InstallDirectory", installDirectory);
|
||||
script.AddVariable("GameManifest", manifest);
|
||||
script.AddVariable("DefaultInstallDirectory", Settings.InstallDirectory);
|
||||
script.AddVariable("ServerAddress", Settings.ServerAddress);
|
||||
script.AddVariable("OldPlayerAlias", oldPlayerAlias);
|
||||
script.AddVariable("NewPlayerAlias", newPlayerAlias);
|
||||
|
||||
return script.Execute();
|
||||
script.UseFile(path);
|
||||
|
||||
return script.Execute();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int RunKeyChangeScript(string installDirectory, string key = "")
|
||||
{
|
||||
var manifest = ManifestHelper.Read(installDirectory);
|
||||
var script = new PowerShellScript();
|
||||
var path = ScriptHelper.GetScriptFilePath(installDirectory, SDK.Enums.ScriptType.KeyChange);
|
||||
|
||||
if (String.IsNullOrEmpty(key))
|
||||
key = LANCommanderClient.GetAllocatedKey(manifest.Id);
|
||||
if (File.Exists(path))
|
||||
{
|
||||
var script = new PowerShellScript();
|
||||
|
||||
script.AddVariable("InstallDirectory", installDirectory);
|
||||
script.AddVariable("GameManifest", manifest);
|
||||
script.AddVariable("DefaultInstallDirectory", Settings.InstallDirectory);
|
||||
script.AddVariable("ServerAddress", Settings.ServerAddress);
|
||||
script.AddVariable("AllocatedKey", key);
|
||||
if (String.IsNullOrEmpty(key))
|
||||
key = LANCommanderClient.GetAllocatedKey(manifest.Id);
|
||||
|
||||
script.UseFile(ScriptHelper.GetScriptFilePath(installDirectory, SDK.Enums.ScriptType.KeyChange));
|
||||
script.AddVariable("InstallDirectory", installDirectory);
|
||||
script.AddVariable("GameManifest", manifest);
|
||||
script.AddVariable("DefaultInstallDirectory", Settings.InstallDirectory);
|
||||
script.AddVariable("ServerAddress", Settings.ServerAddress);
|
||||
script.AddVariable("AllocatedKey", key);
|
||||
|
||||
return script.Execute();
|
||||
script.UseFile(path);
|
||||
|
||||
return script.Execute();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace LANCommander.PlaynitePlugin
|
|||
{
|
||||
var scriptPath = ScriptHelper.GetScriptFilePath(Game.InstallDirectory, SDK.Enums.ScriptType.Uninstall);
|
||||
|
||||
if (!String.IsNullOrEmpty(scriptPath))
|
||||
if (!String.IsNullOrEmpty(scriptPath) && File.Exists(scriptPath))
|
||||
{
|
||||
var manifest = ManifestHelper.Read(Game.InstallDirectory);
|
||||
var script = new PowerShellScript();
|
||||
|
|
Loading…
Reference in New Issue