public void Run() { SteamRunningHelper.EnsureSteamIsRunning(RunSteamIfNeeded); _acLauncher = FileUtils.GetAcLauncherFilename(AcRoot); _acLauncherBackup = _acLauncher.ApartFromLast(".exe", StringComparison.OrdinalIgnoreCase) + "_backup_ts.exe"; if (File.Exists(_acLauncherBackup) && new FileInfo(_acLauncher).Length > ApproximateAcstarterSize) { File.Move(_acLauncherBackup, _acLauncherBackup.ApartFromLast(".exe", StringComparison.OrdinalIgnoreCase) + "_" + DateTime.Now.Ticks + ".exe"); } if (!File.Exists(_acLauncherBackup)) { File.Move(_acLauncher, _acLauncherBackup); } if (!File.Exists(_acLauncher)) { File.WriteAllBytes(_acLauncher, Resources.AcStarter); } _launcherProcess = Process.Start(new ProcessStartInfo { WorkingDirectory = AcRoot, FileName = Path.GetFileName(_acLauncher), Arguments = $"--first-stage {AcsName}" }); }
private void RunInner() { AppIdStarter.CleanUpForOthers(); SteamRunningHelper.EnsureSteamIsRunning(RunSteamIfNeeded, false); SetAcX86Param(); if (!IsAssettoCorsaRunning) { TryToRunAssettoCorsa(); throw new InformativeException("Running AssettoCorsa.exe is required", "You’re using Module Starter, it works only though original launcher."); } var backdoor = BackdoorFilename; if (!File.Exists(backdoor)) { throw new InformativeException("Connection file is missing", "Make sure UI module is working properly."); } RaisePreviewRunEvent(AcsFilename); IniFile.Write(backdoor, "COMMAND", "CURRENT", JsonConvert.SerializeObject(new { name = @"start" }).ToBase64()); Thread.Sleep(2000); if (new IniFile(backdoor)["COMMAND"].GetNonEmpty("CURRENT") != null) { throw new InformativeException("UI module does not respond", "Make sure UI module is working properly."); } }
public override async Task RunAsync(CancellationToken cancellation) { await Task.Run(() => SteamRunningHelper.EnsureSteamIsRunning(RunSteamIfNeeded)); new IniFile(FileUtils.GetRaceIniFilename()) { ["AUTOSPAWN"] = { ["ACTIVE"] = true, ["__CM_SERVICE"] = true } }.Save(); await Task.Run(() => InstallSidePassage()); if (cancellation.IsCancellationRequested) { return; } var passage = await EstablishConnectionAsync(cancellation); if (cancellation.IsCancellationRequested) { return; } if (passage == null) { throw new InformativeException("Can’t connect to side passage", "Please, make sure AC Service is running well or switch starters."); } passage.Start(AcsName); }
public override void Run() { SteamRunningHelper.EnsureSteamIsRunning(RunSteamIfNeeded); CreateAppIdFile(); GameProcess = Process.Start(new ProcessStartInfo { FileName = AcsFilename, WorkingDirectory = AcRootDirectory.Instance.RequireValue }); }
private static async Task LaunchSteam() { await Task.Delay(500); await Task.Run(() => { try { SteamRunningHelper.EnsureSteamIsRunning(true, false); } catch (Exception e) { Logging.Error(e); } }); }
public override void Run() { SteamRunningHelper.EnsureSteamIsRunning(RunSteamIfNeeded, false); CreateAppIdFile(); RaisePreviewRunEvent(AcsFilename); GameProcess = Process.Start(new ProcessStartInfo { FileName = AcsFilename, WorkingDirectory = AcRootDirectory.Instance.RequireValue }); if (GameProcess != null && OptionTrackProcess) { ChildProcessTracker.AddProcess(GameProcess); } }
public override void Run() { SteamRunningHelper.EnsureSteamIsRunning(RunSteamIfNeeded); InstallSidePassage(); var passage = EstablishConnection(); if (passage == null) { throw new InformativeException("Can’t connect to side passage", "Please, make sure AC Service (replacement for AssettoCorsa.exe — don’t worry, original file is renamed to AssettoCorsa_original.exe, and you can always restore it) is running well or switch starters."); } passage.Start(AcsName); }
private void RunInner() { SteamRunningHelper.EnsureSteamIsRunning(RunSteamIfNeeded); new IniFile(FileUtils.GetRaceIniFilename()) { ["AUTOSPAWN"] = { ["ACTIVE"] = true, ["__CM_SERVICE"] = IniFile.Nothing } }.Save(); SetAcX86Param(); LauncherProcess = Process.Start(new ProcessStartInfo { FileName = LauncherFilename, WorkingDirectory = AcRootDirectory.Instance.RequireValue }); }
private static string GetAchievementsInner() { SteamRunningHelper.EnsureSteamIsRunning(SettingsHolder.Drive.RunSteamIfNeeded); CreateAppIdFile(); var reader = Path.Combine(AcRootDirectory.Instance.RequireValue, "SteamStatisticsReader.exe"); var output = new StringBuilder(); using (var process = new Process { StartInfo = { FileName = reader, WorkingDirectory = AcRootDirectory.Instance.RequireValue, Arguments = "-c", CreateNoWindow = true, RedirectStandardInput = true, RedirectStandardOutput = true, UseShellExecute = false }, EnableRaisingEvents = true }) { process.Start(); process.OutputDataReceived += (sender, args) => { if (args.Data != null) { output.Append(args.Data); } }; process.BeginOutputReadLine(); process.WaitForExit(10000); if (!process.HasExited) { process.Kill(); } } var result = Regex.Replace(output.ToString(), @"\r+|\s+|\n$", ""); return(string.IsNullOrEmpty(result) ? "{}" : result); }
private void RunInner() { SteamRunningHelper.EnsureSteamIsRunning(RunSteamIfNeeded, false); new IniFile(AcPaths.GetRaceIniFilename()) { ["AUTOSPAWN"] = { ["ACTIVE"] = true, ["__CM_SERVICE"] = IniFile.Nothing } }.Save(); SetAcX86Param(); RaisePreviewRunEvent(AcsFilename); LauncherProcess = Process.Start(new ProcessStartInfo { FileName = LauncherFilename, WorkingDirectory = AcRootDirectory.Instance.RequireValue }); if (LauncherProcess != null && OptionTrackProcess) { ChildProcessTracker.AddProcess(LauncherProcess); } }
private static string GetAchievementsInner() { SteamRunningHelper.EnsureSteamIsRunning(SettingsHolder.Drive.RunSteamIfNeeded, false); CreateAppIdFile(); var outputName = "SteamStatisticsReader-out.json"; var reader = Path.Combine(AcRootDirectory.Instance.RequireValue, "SteamStatisticsReader.exe"); var readerBackup = FileUtils.EnsureUnique(reader + ".bak"); try { if (File.Exists(reader)) { File.Move(reader, readerBackup); } File.Copy(MainExecutingFile.Location, reader); using (var process = new Process { StartInfo = { FileName = reader, WorkingDirectory = AcRootDirectory.Instance.RequireValue, Arguments = $"--out={outputName}", CreateNoWindow = true, UseShellExecute = false } }) { process.Start(); process.WaitForExit(10000); if (!process.HasExited) { process.Kill(); } } Thread.Sleep(500); var outputFilename = Path.Combine(AcRootDirectory.Instance.RequireValue, outputName); Logging.Debug("outputFilename=" + outputFilename); Logging.Debug("File.Exists(outputFilename)=" + File.Exists(outputFilename)); if (!File.Exists(outputFilename)) { throw new Exception("Custom Steam statistics reader failed to do its job properly"); } var result = File.ReadAllText(outputFilename); FileUtils.TryToDelete(outputFilename); return(result); } finally { if (File.Exists(readerBackup)) { File.Delete(reader); File.Move(readerBackup, reader); } } /*var output = new StringBuilder(); * using (var process = new Process { * StartInfo = { * FileName = reader, * WorkingDirectory = AcRootDirectory.Instance.RequireValue, * Arguments = "-c", * CreateNoWindow = true, * RedirectStandardInput = true, * RedirectStandardOutput = true, * UseShellExecute = false * }, * EnableRaisingEvents = true * }) { * process.Start(); * process.OutputDataReceived += (sender, args) => { * if (args.Data != null) output.Append(args.Data); * }; * process.BeginOutputReadLine(); * process.WaitForExit(10000); * if (!process.HasExited) { * process.Kill(); * } * } * * var result = Regex.Replace(output.ToString(), @"\r+|\s+|\n$", ""); * return string.IsNullOrEmpty(result) ? "{}" : result;*/ }