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