Run post-install scripts
parent
dd50bb11df
commit
d39c75d0ab
|
@ -19,11 +19,15 @@ namespace LANCommander.PlaynitePlugin
|
||||||
public class LANCommanderInstallController : InstallController
|
public class LANCommanderInstallController : InstallController
|
||||||
{
|
{
|
||||||
private LANCommanderLibraryPlugin Plugin;
|
private LANCommanderLibraryPlugin Plugin;
|
||||||
|
private PowerShellRuntime PowerShellRuntime;
|
||||||
|
private Game PlayniteGame;
|
||||||
|
|
||||||
public LANCommanderInstallController(LANCommanderLibraryPlugin plugin, Game game) : base(game)
|
public LANCommanderInstallController(LANCommanderLibraryPlugin plugin, Game game) : base(game)
|
||||||
{
|
{
|
||||||
Name = "Install using LANCommander";
|
Name = "Install using LANCommander";
|
||||||
Plugin = plugin;
|
Plugin = plugin;
|
||||||
|
PlayniteGame = game;
|
||||||
|
PowerShellRuntime = new PowerShellRuntime();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Install(InstallActionArgs args)
|
public override void Install(InstallActionArgs args)
|
||||||
|
@ -36,13 +40,18 @@ namespace LANCommander.PlaynitePlugin
|
||||||
var tempFile = Download(game);
|
var tempFile = Download(game);
|
||||||
|
|
||||||
var installDirectory = Extract(game, tempFile);
|
var installDirectory = Extract(game, tempFile);
|
||||||
|
|
||||||
var installInfo = new GameInstallationData()
|
var installInfo = new GameInstallationData()
|
||||||
{
|
{
|
||||||
InstallDirectory = installDirectory
|
InstallDirectory = installDirectory
|
||||||
};
|
};
|
||||||
|
|
||||||
|
PlayniteGame.InstallDirectory = installDirectory;
|
||||||
|
|
||||||
File.WriteAllText(Path.Combine(installDirectory, "_manifest.yml"), GetManifest(gameId));
|
File.WriteAllText(Path.Combine(installDirectory, "_manifest.yml"), GetManifest(gameId));
|
||||||
|
|
||||||
|
PowerShellRuntime.RunInstallScript(PlayniteGame);
|
||||||
|
|
||||||
InvokeOnInstalled(new GameInstalledEventArgs(installInfo));
|
InvokeOnInstalled(new GameInstalledEventArgs(installInfo));
|
||||||
|
|
||||||
Plugin.UpdateGamesFromManifest();
|
Plugin.UpdateGamesFromManifest();
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using Playnite.SDK.Models;
|
using Playnite.SDK.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Management.Automation;
|
using System.Management.Automation;
|
||||||
|
@ -13,13 +14,13 @@ namespace LANCommander.PlaynitePlugin
|
||||||
{
|
{
|
||||||
public void RunScript(string script, Dictionary<string, object> parameters)
|
public void RunScript(string script, Dictionary<string, object> parameters)
|
||||||
{
|
{
|
||||||
using (PowerShell ps = PowerShell.Create())
|
var process = new Process();
|
||||||
{
|
process.StartInfo.FileName = "powershell.exe";
|
||||||
ps.AddScript(script);
|
process.StartInfo.UseShellExecute = true;
|
||||||
ps.AddParameters(parameters);
|
process.StartInfo.Verb = "runas";
|
||||||
|
process.StartInfo.Arguments = $@"-ExecutionPolicy Unrestricted -File ""{script}""";
|
||||||
var output = ps.Invoke();
|
process.Start();
|
||||||
}
|
process.WaitForExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RunInstallScript(Game game)
|
public void RunInstallScript(Game game)
|
||||||
|
|
Loading…
Reference in New Issue