private static void GetScoopInfo() { try { _scoopUserPath = Environment.GetEnvironmentVariable("SCOOP"); if (string.IsNullOrEmpty(_scoopUserPath)) { _scoopUserPath = Path.Combine(WindowsTools.GetEnvironmentPath(CSIDL.CSIDL_PROFILE), "scoop"); } _scoopGlobalPath = Environment.GetEnvironmentVariable("SCOOP_GLOBAL"); if (string.IsNullOrEmpty(_scoopGlobalPath)) { _scoopGlobalPath = Path.Combine(WindowsTools.GetEnvironmentPath(CSIDL.CSIDL_COMMON_APPDATA), "scoop"); } _scriptPath = Path.Combine(_scoopUserPath, "shims\\scoop.ps1"); if (File.Exists(_scriptPath)) { if (!File.Exists(PathTools.GetFullPathOfExecutable("powershell.exe"))) { throw new InvalidOperationException(@"Detected Scoop program installer, but failed to detect PowerShell"); } _scoopIsAvailable = true; } } catch (SystemException ex) { Console.WriteLine(ex); } }
static ScriptManager() { var assemblyLocation = Assembly.GetExecutingAssembly().Location; if (assemblyLocation.EndsWith(".exe")) { assemblyLocation = Path.GetDirectoryName(assemblyLocation); } ScriptDir = Path.Combine(assemblyLocation ?? string.Empty, @"Resources\Scripts"); try { PowershellExists = File.Exists(PathTools.GetFullPathOfExecutable("powershell.exe")); } catch (SystemException) { PowershellExists = false; } }
private static void GetChocoInfo() { try { var chocoPath = PathTools.GetFullPathOfExecutable("choco.exe"); if (string.IsNullOrEmpty(chocoPath)) { return; } var result = StartProcessAndReadOutput(chocoPath, string.Empty); if (result.StartsWith("Chocolatey", StringComparison.Ordinal)) { _chocoLocation = chocoPath; _chocoIsAvailable = true; } } catch (SystemException ex) { Console.WriteLine(ex); } }
static ScriptFactory() { ScriptDir = Path.Combine(UninstallToolsGlobalConfig.AssemblyLocation, @"Resources\Scripts"); EntryProps = typeof(ApplicationUninstallerEntry) .GetProperties(BindingFlags.Instance | BindingFlags.Public) .Where(p => p.CanWrite && p.PropertyType == typeof(string)) .ToArray(); SystemIconProps = typeof(SystemIcons) .GetProperties(BindingFlags.Static | BindingFlags.Public) .Where(p => p.CanRead) .ToArray(); try { PowershellExists = File.Exists(PathTools.GetFullPathOfExecutable("powershell.exe")); } catch (SystemException) { PowershellExists = false; } }