public OperatingSystemFacade() { Assembly = new AssemblyFacade(); Dialog = new DialogFacade(); Directory = new DirectoryFacade(); Environment = new Environment(); File = new FileFacade(); MemoryMappedFiles = new MemoryMappedFileFactory(); ProcessLocator = new ProcessLocator(); ProcessStarter = new ProcessStarter(); Registry = new Registry(); }
public void CheckTestFile(string url, string expectedContent) { Console.WriteLine ("Checking test file..."); Console.WriteLine (""); Console.WriteLine ("URL:"); Console.WriteLine (url); Console.WriteLine (""); Console.WriteLine ("Expected content:"); Console.WriteLine (expectedContent); Console.WriteLine (""); bool foundMatch = false; int currentTry = 1; // Keep retrying as it takes time for changes to propagate while (!foundMatch && currentTry <= MaxTries) { Console.WriteLine ("Try #" + currentTry); var starter = new ProcessStarter (); starter.Start ("curl -s " + url); var outputText = starter.Output.Trim (); Console.WriteLine ("Found contents:"); Console.WriteLine ("\"" + (String.IsNullOrEmpty(outputText) ? "[empty]" : outputText) + "\""); if (outputText.Trim() == expectedContent.Trim()) { foundMatch = true; Console.WriteLine ("Successful match"); } else Console.WriteLine ("Failed to match"); currentTry++; if (!foundMatch) Thread.Sleep (DelayBetweenTries); } Assert.IsTrue (foundMatch); }
/// <summary> /// Starts a new process. /// - If the file is executable then it will execute that file. /// - If the file file is resistered to be opened with another application /// then it will be opened with that application /// - If the file doesnt have an assigned application then Windows Explorer openes it's directory. /// </summary> /// <param name="fullFileName">The full path and name of the file.</param> public void StartProcess(String fullFileName) { ProcessStarter processStarter = new ProcessStarter(fullFileName); processStarter.Perform(); }
public static void StartClient() { ProcessStarter.StartProcess(ClientExecPath, string.Empty); }
public bool ConvertVideoToMicro(Game game, bool overwrite) { var videoPath = extraMetadataHelper.GetGameVideoPath(game, true); var videoMicroPath = extraMetadataHelper.GetGameVideoMicroPath(game, true); if (!File.Exists(videoPath) || (File.Exists(videoMicroPath) && !overwrite)) { return(false); } var videoInfo = GetVideoInformation(videoPath); if (videoInfo == null) { return(false); } // It's needed to use invariant culture when parsing because ffprobe output durantion // uses a dot as decimal separator and some regions use other symbols for this. var videoDuration = double.Parse(videoInfo.Streams[0].Duration, CultureInfo.InvariantCulture); var success = true; if (videoDuration < 14) { var actionNeeded = GetIsConversionNeeded(videoInfo); if (actionNeeded == VideoActionNeeded.Invalid) { success = false; } else if (actionNeeded == VideoActionNeeded.Conversion) { // Scale parameter needs to be used because otherwise ffmpeg // will fail if a dimension is not divisible by 2. var args = $"-y -i \"{videoPath}\" -c:v libx264 -c:a mp3 -vf scale=trunc(iw/2)*2:trunc(ih/2)*2 -pix_fmt yuv420p -an \"{videoMicroPath}\""; var result = ProcessStarter.StartProcessWait(settings.FfmpegPath, args, Path.GetDirectoryName(settings.FfmpegPath), true, out var stdOut, out var stdErr); if (result != 0) { logger.Error($"Failed to process video in ffmpeg: {result}, {stdErr}"); success = false; } } else { // Scale parameter needs to be used because otherwise ffmpeg // will fail if a dimension is not divisible by 2. var args = $"-y -i \"{videoPath}\" -c:v copy -an \"{videoMicroPath}\""; var result = ProcessStarter.StartProcessWait(settings.FfmpegPath, args, Path.GetDirectoryName(settings.FfmpegPath), true, out var stdOut, out var stdErr); if (result != 0) { logger.Error($"Failed to process video in ffmpeg: {result}, {stdErr}"); success = false; } } } else { var rangeStringList = new List <string>(); var clipDuration = 1; int[] startPercentageVideo = { 15, 25, 35, 45, 55, 65 }; foreach (var percentage in startPercentageVideo) { double clipStart = (percentage * videoDuration) / 100; double clipEnd = clipStart + clipDuration; rangeStringList.Add(string.Format("between(t,{0:N2},{1:N2})", clipStart.ToString(CultureInfo.InvariantCulture), clipEnd.ToString(CultureInfo.InvariantCulture))); } var selectString = $"\"select = '{string.Join("+", rangeStringList)}', setpts = N / FRAME_RATE / TB, scale = trunc(iw / 2) * 2:trunc(ih / 2) * 2\""; var args = $"-y -i \"{videoPath}\" -vf {selectString} -c:v libx264 -pix_fmt yuv420p -an \"{videoMicroPath}\""; var result = ProcessStarter.StartProcessWait(settings.FfmpegPath, args, Path.GetDirectoryName(settings.FfmpegPath), true, out var stdOut, out var stdErr); if (result != 0) { logger.Error($"Failed to process video in ffmpeg: {result}, {stdErr}"); success = false; } } return(success); }
public override void Uninstall() { ReleaseResources(); ProcessStarter.StartUrl(@"steam://uninstall/" + Game.ProviderId); StartUninstallWatcher(); }
public override void Uninstall() { ReleaseResources(); ProcessStarter.StartProcess("appwiz.cpl", string.Empty); StartUninstallWatcher(); }
public void Execute() { var executer = new ProcessStarter(FullPath); executer.Execute(); }
public SetUpFromLocalScriptLauncher() { Starter = new ProcessStarter(); }
public DeviceSerialHelper(CLIContext context) { Context = context; Starter = new ProcessStarter(context.IndexDirectory); Extractor = new DeviceInfoSerialExtractor(); }
public static void Start(PacketSpy packetSpy, Process process) { PacketSpyStarter starter = new ProcessStarter(packetSpy, process); Start(starter); }
public override void Install() { ProcessStarter.StartUrl($"twitch://fuel/"); StartInstallWatcher(); }
public override void Uninstall() { ReleaseResources(); ProcessStarter.StartProcess(Twitch.GameRemoverPath, $"-m Game -p {Game.GameId}"); StartUninstallWatcher(); }
public SolutionBuilder(string buildMode) { BuildMode = buildMode; Starter = new ProcessStarter(); }
public SolutionBuilder() { Starter = new ProcessStarter(); }
public ScriptLauncher() { Starter = new ProcessStarter(); }
public Gitter() { Starter = new ProcessStarter(); }
private bool UninstallSuperfish(string AddRemoveRegistryKey) { bool AppRemoved = false; bool FoundInAddRemoveRegistry = false; bool TryManualRemove = true; // Always try to manually remove superfish unless the uninstall finishes string Uninstall = null; try { // Try to stop/kill Superfish services and processes StopAllSuperfishProcesses(); Uninstall = CheckAddRemoveRegistry(AddRemoveRegistryKey); if (FoundInAddRemoveRegistry = ((!String.IsNullOrWhiteSpace(Uninstall)))) { if (System.IO.File.Exists(Uninstall)) { if (AppRemoved = (0 == ProcessStarter.StartWithWindow(Uninstall, true))) { // Apparently the uninstall does NOT wait - it returns right away // So wait (45 seconds) for the uninstall program to get removed for (int i = 0; ((System.IO.File.Exists(Uninstall)) && (i < 90)); i++) { System.Threading.Thread.Sleep(500); } if (!System.IO.File.Exists(Uninstall)) { // You know what... just ALWAYS also try the manual removal as well //TryManualRemove = false; Logging.Logger.Log(Logging.LogSeverity.Information, " Superfish application uninstalled"); } } } } } catch (Exception ex) { Logging.Logger.Log(Logging.LogSeverity.Information, "Exception trying to run uninstall (try MANUAL removal) - " + ex.ToString()); } if (TryManualRemove) { Logging.Logger.Log(Logging.LogSeverity.Information, " Superfish application removal - " + AddRemoveRegistryKey); // Since uninstall may not do it - Try to remove Superfish services RemoveAllSuperfishServices(); // Note: There may be some cases where the uninstall program doesn't exist anymore // In this case - Make sure Add/Remove registry key is DELETED // // Remember the ProgramFiles directory will get removed in "FilesDetector" string DeleteAddRemoveKey = CheckAddRemoveRegistry(AddRemoveRegistryKey, true); // Check to see if we should report something different in the UI if ((!FoundInAddRemoveRegistry) || ((!String.IsNullOrWhiteSpace(Uninstall)) && (!System.IO.File.Exists(Uninstall)))) { AppRemoved = (!String.IsNullOrWhiteSpace(DeleteAddRemoveKey)); } } return(FoundInAddRemoveRegistry && AppRemoved); }
public override void Install() { ReleaseResources(); ProcessStarter.StartUrl($"origin2://game/launch?offerIds={Game.GameId}&autoDownload=true"); StartInstallWatcher(); }
public override void Install() { Dispose(); ProcessStarter.StartUrl($"origin2://game/launch?offerIds={Game.ProviderId}&autoDownload=true"); StartInstallWatcher(); }
public override void Open() { ProcessStarter.StartProcess(Bethesda.ClientExecPath, string.Empty); }
public override void Uninstall() { Dispose(); ProcessStarter.StartProcess("appwiz.cpl", string.Empty); StartUninstallWatcher(); }
private void DisplayPinPage(string url) { // TODO: An in-app browser would be cleaner I guess ProcessStarter.Start(url); }
public override void Uninstall() { Dispose(); ProcessStarter.StartUrl("uplay://uninstall/" + Game.ProviderId); StartUninstallWatcher(); }
private void ExecuteOpenImageCommand() { ProcessStarter.Start(SelectedImage.DisplayUrl.AbsoluteUri); }
private static int Main(string[] args) { XmlConfigurator.Configure(); var logger = LogManager.GetLogger(typeof(Program)); string cmd = null; int exitCode; try { var user = ConfigurationManager.AppSettings["user"]; var password = ConfigurationManager.AppSettings["password"]; var domainname = ConfigurationManager.AppSettings["domain"]; var bin = ConfigurationManager.AppSettings["bin"]; if (String.IsNullOrWhiteSpace(user)) { throw new Exception("Не задано имя пользователя для интерактивного запуска"); } if (String.IsNullOrWhiteSpace(bin)) { throw new Exception("Не задан исполняемый фай"); } cmd = Assembly.GetExecutingAssembly().Location; if (args.Length >= 1) { cmd += " " + args.Implode(" "); } logger.InfoFormat("Попытка запуска отчета: {0}", cmd); if (!args.Any(a => a.StartsWith(AcceessKey))) { cmd += string.Format(" {0}true", AcceessKey); exitCode = ProcessStarter.StartProcessInteractivly(cmd, user, password, domainname); } else { AppDomain domain = null; try { if (!Path.IsPathRooted(bin)) { bin = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, bin)); } var config = bin + ".config"; var setup = new AppDomainSetup { ApplicationBase = Path.GetDirectoryName(bin), ShadowCopyFiles = "true", ConfigurationFile = config }; domain = AppDomain.CreateDomain("freeReportDomain", null, setup); exitCode = domain.ExecuteAssembly(bin, args); } finally { if (domain != null) { AppDomain.Unload(domain); } } } logger.InfoFormat("Отчет {0} отработал успешно", cmd); } catch (Exception exception) { logger.Error("Ошибка при запуске отчета : " + cmd, exception); exitCode = 1; } return(exitCode); }
public MqttBridgeStarter(CLIContext context) { Starter = new ProcessStarter(context.IndexDirectory); Context = context; }
public void Test_Pull() { var workingDirectory = Environment.CurrentDirectory; var processStarter = new ProcessStarter(); Console.WriteLine(""); Console.WriteLine("Setting up source repository..."); Console.WriteLine(""); // Set up the source directory var sourceRepository = Path.GetFullPath("SourceRepo"); Console.WriteLine("Source repo: " + sourceRepository); Directory.CreateDirectory(sourceRepository); Directory.SetCurrentDirectory(sourceRepository); var testFileName = "test.txt"; // Set up the source file var sourceFile = Path.Combine(sourceRepository, testFileName); File.WriteAllText(sourceFile, "Hello world 1"); Console.WriteLine("Source file: " + sourceFile); // Set up the source repository processStarter.Start("git init"); processStarter.Start("git add test.txt"); processStarter.Start("git commit -am 'Initial commit'"); Directory.SetCurrentDirectory(workingDirectory); Console.WriteLine(""); Console.WriteLine("Setting up destination repository and cloning..."); Console.WriteLine(""); // Set up destination directory and clone var destinationRepository = Path.GetFullPath("DestinationRepo"); Console.WriteLine("Destination repo: " + destinationRepository); //Directory.CreateDirectory (sourceRepository); processStarter.Start("git clone -v " + sourceRepository + " " + destinationRepository); var destinationFile = Path.Combine(destinationRepository, testFileName); Console.WriteLine("Destination file: " + destinationFile); Assert.IsTrue(File.Exists(destinationFile), "File not found: " + destinationFile); Console.WriteLine(""); Console.WriteLine("Editing the source file..."); Console.WriteLine(""); // Change the source file File.WriteAllText(sourceFile, "Hello world 2"); Directory.SetCurrentDirectory(sourceRepository); processStarter.Start("git commit -am 'Updated test file'"); Directory.SetCurrentDirectory(destinationRepository); var gitter = new Gitter(); var repository = gitter.Open(destinationRepository); Console.WriteLine(""); Console.WriteLine("Pulling changes to destination repository..."); Console.WriteLine(""); repository.Pull("origin"); var expectedContent = "Hello world 2"; Assert.AreEqual(expectedContent, File.ReadAllText(destinationFile), "Invalid content"); }
public static void Start( PacketSpy packetSpy, Process process ) { PacketSpyStarter starter = new ProcessStarter( packetSpy, process ); Start( starter ); }
public override void Play() { OnStarting(this, new GameControllerEventArgs(this, 0)); var startViaLauncher = true; GameConfiguration gameConfig = null; if (settings.StartGamesWithoutLauncher) { try { gameConfig = AmazonGames.GetGameConfiguration(Game.InstallDirectory); if (AmazonGames.GetGameRequiresClient(gameConfig)) { startViaLauncher = true; } else { startViaLauncher = false; } } catch (Exception e) when(!Debugger.IsAttached) { logger.Error(e, "Failed to get local game configuration."); } } if (startViaLauncher) { ProcessStarter.StartUrl($"amazon-games://play/{Game.GameId}"); } else { var exePath = Path.Combine(Game.InstallDirectory, gameConfig.Main.Command); var workDir = Game.InstallDirectory; if (!gameConfig.Main.WorkingSubdirOverride.IsNullOrEmpty()) { workDir = Path.Combine(Game.InstallDirectory, gameConfig.Main.WorkingSubdirOverride); } string args = null; if (gameConfig.Main.Args.HasNonEmptyItems()) { args = string.Join(" ", gameConfig.Main.Args); } ProcessStarter.StartProcess(exePath, args, workDir); } if (Directory.Exists(Game.InstallDirectory)) { stopWatch = Stopwatch.StartNew(); procMon = new ProcessMonitor(); procMon.TreeStarted += ProcMon_TreeStarted; procMon.TreeDestroyed += Monitor_TreeDestroyed; procMon.WatchDirectoryProcesses(Game.InstallDirectory, false); } else { OnStopped(this, new GameControllerEventArgs(this, 0)); } }
public override void Uninstall() { ReleaseResources(); ProcessStarter.StartUrl("uplay://uninstall/" + Game.GameId); StartUninstallWatcher(); }
public override void Uninstall() { CheckItchInstallStatus(); ProcessStarter.StartUrl("itch://library/installed"); StartUninstallWatcher(); }