public static void Initialize() { using (new Mutex(true, ProcessEx.CurrentName, out var newInstance)) { #if x86 if (Environment.Is64BitOperatingSystem) { var curPath64 = PathEx.Combine(PathEx.LocalDir, $"{ProcessEx.CurrentName}64.exe"); if (File.Exists(curPath64)) { ProcessEx.Start(curPath64, EnvironmentEx.CommandLine(false)); return; } } #endif if (!string.IsNullOrWhiteSpace(Attributes.DefIni) && !string.IsNullOrWhiteSpace(Attributes.ConfigPath) && !File.Exists(Attributes.ConfigPath)) { try { File.WriteAllText(Attributes.ConfigPath, Attributes.DefIni); } catch (UnauthorizedAccessException) { Elevation.RestartAsAdministrator(); } }
private static void Main() { Log.AllowLogging(); using (new Mutex(true, ProcessEx.CurrentName, out bool newInstance)) { if (!newInstance) { return; } var appDir = PathEx.Combine(PathEx.LocalDir, "App\\Defraggler"); if (!Directory.Exists(appDir)) { return; } var appPath = Path.Combine(appDir, "Defraggler.exe"); var updaterPath = Path.Combine(appDir, "DefragglerUpdater.exe"); if (ProcessEx.IsRunning(Path.GetFileNameWithoutExtension(appPath)) || !File.Exists(updaterPath) || ProcessEx.IsRunning(Path.GetFileNameWithoutExtension(updaterPath))) { return; } var dataDir = PathEx.Combine(PathEx.LocalDir, "Data"); var fileMap = new Dictionary <string, string> { { PathEx.Combine(appDir, "defraggler.ini"), PathEx.Combine(dataDir, "defraggler.ini") }, { PathEx.Combine(appDir, "statistics.bin"), PathEx.Combine(dataDir, "statistics.bin") } }; Helper.ApplicationStart(updaterPath, "/silent", null); if (!File.Exists(appPath)) { var updIniPath = Path.ChangeExtension(updaterPath, ".ini"); if (!string.IsNullOrEmpty(updIniPath) && File.Exists(updIniPath)) { File.Delete(updIniPath); } return; } Helper.FileForwarding(Helper.Options.Start, fileMap); var portableDat = Path.Combine(appDir, "portable.dat"); if (!File.Exists(portableDat)) { File.WriteAllText(portableDat, @"#PORTABLE#"); } Helper.ApplicationStart(appPath, EnvironmentEx.CommandLine(false), false); Helper.FileForwarding(Helper.Options.Exit, fileMap); } }
private static void Main() { Log.AllowLogging(); using (new Mutex(true, ProcessEx.CurrentName, out bool newInstance)) { var appPath = PathEx.Combine(PathEx.LocalDir, "App\\hexeditmx\\hexeditmx.exe"); if (!File.Exists(appPath)) { return; } if (!newInstance) { ProcessEx.Start(appPath, EnvironmentEx.CommandLine()); return; } if (ProcessEx.IsRunning(Path.GetFileNameWithoutExtension(appPath))) { return; } var regKeys = new[] { "HKCU\\Software\\NEXT-Soft" }; Helper.RegForwarding(Helper.Options.Start, regKeys); Helper.ApplicationStart(appPath, EnvironmentEx.CommandLine(), false); Helper.RegForwarding(Helper.Options.Exit, regKeys); } }
private static void Main() { using (new Mutex(true, ProcessEx.CurrentName, out bool newInstance)) { if (!newInstance) { return; } var appPath = PathEx.Combine(PathEx.LocalDir, "App\\SharpKeys\\SharpKeys.exe"); if (!File.Exists(appPath)) { return; } const string firstKey = "HKCU\\Software\\RandyRants"; const string lastKey = "HKCU\\Software\\RandyRants\\SharpKeys"; Helper.RegForwarding(Helper.Options.Start, lastKey); Reg.Write(lastKey, "ShowWarning", 1, RegistryValueKind.DWord); Helper.ApplicationStart(appPath, EnvironmentEx.CommandLine(false), false); Helper.RegForwarding(Helper.Options.Exit, firstKey); if (!Reg.GetSubKeys(firstKey).Any()) { Reg.RemoveSubKey(firstKey); } } }
private static void Main() { Log.AllowLogging(); using (new Mutex(true, ProcessEx.CurrentName, out bool newInstance)) { if (!newInstance) { return; } var appPath = PathEx.Combine(PathEx.LocalDir, "App\\AIDA64\\aida64.exe"); if (!File.Exists(appPath) || ProcessEx.IsRunning(Path.GetFileNameWithoutExtension(appPath))) { return; } const string iniPath = "%CurDir%\\Data\\aida64.ini"; var iniMap = new Dictionary <string, Dictionary <string, string> > { { "Generic", new Dictionary <string, string> { { "NoRegistry", "1" }, { "NetUpdateFreq", "1" }, { "ReportFileFolder", PathEx.Combine(PathEx.LocalDir, "Data\\Reports") } } } }; var fileMap = new Dictionary <string, string> { { "%CurDir%\\App\\AIDA64\\aida64.ini", "%CurDir%\\Data\\aida64.ini" }, { "%CurDir%\\App\\AIDA64\\aida64.reg.ini", "%CurDir%\\Data\\aida64.reg.ini" } }; Helper.ConfigOverwrite(iniMap, iniPath); Helper.FileForwarding(Helper.Options.Start, fileMap, true); Helper.ApplicationStart(appPath, EnvironmentEx.CommandLine(false), false); Helper.FileForwarding(Helper.Options.Exit, fileMap, true); } }
private static void Main() { Log.AllowLogging(); using (new Mutex(true, ProcessEx.CurrentName, out bool newInstance)) { if (!newInstance) { return; } var appPath = PathEx.Combine("%CurDir%\\App\\FormatFactory\\FormatFactory.exe"); if (!File.Exists(appPath) || ProcessEx.IsRunning(Path.GetFileNameWithoutExtension(appPath))) { return; } var regKeys = new[] { "HKCU\\Software\\FreeTime", "HKCU\\Software\\FreeTime\\FormatFactory" }; Helper.RegForwarding(Helper.Options.Start, regKeys[0]); Reg.Write(regKeys[0], "FormatFactory", Path.GetDirectoryName(appPath), RegistryValueKind.String); Reg.Write(regKeys[1], "CheckNewVersion", 0, RegistryValueKind.DWord); Reg.Write(regKeys[1], "CodecInstalled", 0, RegistryValueKind.DWord); Reg.Write(regKeys[1], "OptionActivePage", 0, RegistryValueKind.DWord); Reg.Write(regKeys[1], "OutputDir", PathEx.Combine("%CurDir%\\Data\\Output"), RegistryValueKind.String); Reg.Write(regKeys[1], "UseCount", 1, RegistryValueKind.DWord); #if Legacy Reg.Write(regKeys[1], "Skin", 2, RegistryValueKind.DWord); Reg.Write(regKeys[1], "Version", "3.3.5", RegistryValueKind.String); #else Reg.Write(regKeys[1], "Skin", 6, RegistryValueKind.DWord); Reg.Write(regKeys[1], "StartMethodTab", 0, RegistryValueKind.DWord); try { var fvi = FileVersionInfo.GetVersionInfo(appPath); var str = new List <string>(fvi.ProductVersion.Split('.')).GetRange(0, 3).Join('.'); Reg.Write(regKeys[1], "Version", str, RegistryValueKind.String); } catch (Exception ex) { Log.Write(ex); } #endif Helper.ApplicationStart(appPath, EnvironmentEx.CommandLine(false), false); Helper.RegForwarding(Helper.Options.Exit, regKeys[0]); } }
internal static void Initialize() { #if x86 if (Environment.Is64BitOperatingSystem) { var appsDownloader64 = PathEx.Combine(PathEx.LocalDir, $"{ProcessEx.CurrentName}64.exe"); if (File.Exists(appsDownloader64)) { ProcessEx.Start(appsDownloader64, EnvironmentEx.CommandLine(false)); Environment.ExitCode = 0; Environment.Exit(Environment.ExitCode); } } #endif Log.FileDir = Path.Combine(CorePaths.TempDir, "Logs"); Ini.SetFile(PathEx.LocalDir, "..", "Settings.ini"); Ini.SortBySections = new[] { Section, "Launcher" }; Log.AllowLogging(Ini.FilePath, "DebugMode", Ini.GetRegex(false)); if (Elevation.IsAdministrator) { var path = Path.Combine("HKCU\\Software\\Portable Apps Suite", CorePaths.HomeDir.Encrypt(ChecksumAlgorithms.Adler32), ProcessEx.CurrentId.ToString()); if (Reg.CreateNewSubKey(path)) { AppDomain.CurrentDomain.ProcessExit += (s, e) => Reg.RemoveSubKey(path); } } if (Recovery.AppsSuiteIsHealthy()) { return; } Environment.ExitCode = 1; Environment.Exit(Environment.ExitCode); }
private static void Main() { Log.AllowLogging(); using (new Mutex(true, ProcessEx.CurrentName, out bool newInstance)) { var appPath = PathEx.Combine(PathEx.LocalDir, "App\\mpTrim\\mpTrim.exe"); if (!File.Exists(appPath)) { return; } if (!newInstance) { ProcessEx.Start(appPath, EnvironmentEx.CommandLine(false)); return; } const string regKey = "HKCU\\Software\\mpTrim"; Helper.RegForwarding(Helper.Options.Start, regKey); var regPath = PathEx.Combine(PathEx.LocalDir, "Data\\settings.reg"); if (!File.Exists(regPath)) { var screenWidth = Screen.PrimaryScreen.WorkingArea.Width; const int windowWidth = 335; var windowLeft = (int)Math.Round(screenWidth / 2d - windowWidth / 2d); Reg.Write(regKey, "MainFormLeft", windowLeft, RegistryValueKind.DWord); var screenHeight = Screen.PrimaryScreen.WorkingArea.Height; const int windowHeight = 410; var windowTop = (int)Math.Round(screenHeight / 2d - windowHeight / 2d); Reg.Write(regKey, "MainFormTop", windowTop, RegistryValueKind.DWord); } Helper.ApplicationStart(appPath, EnvironmentEx.CommandLine(false), false); Helper.RegForwarding(Helper.Options.Exit, regKey); } }
private static void Main() { Log.FileDir = PathEx.Combine(PathEx.LocalDir, "..\\Documents\\.cache\\logs"); Ini.SetFile(HomePath, "Settings.ini"); Ini.SortBySections = new[] { "History", "Host", "Settings" }; Log.AllowLogging(Ini.FilePath); #if x86 string appsDownloader64; if (Environment.Is64BitOperatingSystem && File.Exists(appsDownloader64 = PathEx.Combine(PathEx.LocalDir, $"{ProcessEx.CurrentName}64.exe"))) { ProcessEx.Start(appsDownloader64, EnvironmentEx.CommandLine(false)); return; } #endif if (!RequirementsAvailable()) { var updPath = PathEx.Combine(PathEx.LocalDir, "Updater.exe"); if (File.Exists(updPath)) { ProcessEx.Start(updPath); } else { Lang.ResourcesNamespace = typeof(Program).Namespace; if (MessageBox.Show(Lang.GetText(nameof(en_US.RequirementsErrorMsg)), Resources.Title, MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.Yes) { Process.Start(PathEx.AltCombine(Resources.GitProfileUri, Resources.GitReleasesPath)); } } return; } var instanceKey = PathEx.LocalPath.GetHashCode().ToString(); using (new Mutex(true, instanceKey, out bool newInstance)) { var allowInstance = newInstance; if (!allowInstance) { var instances = ProcessEx.GetInstances(PathEx.LocalPath); var count = 0; foreach (var instance in instances) { if (instance?.GetCommandLine()?.ContainsEx(ActionGuid.UpdateInstance) == true) { count++; } instance?.Dispose(); } allowInstance = count == 1; } if (!allowInstance) { return; } MessageBoxEx.TopMost = true; Lang.ResourcesNamespace = typeof(Program).Namespace; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm().Plus()); } }
private static void Main() { Log.AllowLogging(); #if x86 var curPath64 = PathEx.Combine(PathEx.LocalDir, "YoloMouse64Portable.exe"); if (Environment.Is64BitOperatingSystem && File.Exists(curPath64)) { ProcessEx.Start(curPath64, EnvironmentEx.CommandLine(false)); return; } var appDir = PathEx.Combine(PathEx.LocalDir, "App\\YoloMouse"); var updaterPath = PathEx.Combine(appDir, "YoloMouseUpdater.exe"); #else var appDir = PathEx.Combine(PathEx.LocalDir, "App\\YoloMouse64"); var updaterPath = PathEx.Combine(appDir, "YoloMouseUpdater64.exe"); #endif using (new Mutex(true, ProcessEx.CurrentName, out bool newInstance)) { if (!newInstance) { return; } var appPath = PathEx.Combine(appDir, "YoloMouse.exe"); if (ProcessEx.IsRunning(Path.GetFileNameWithoutExtension(appPath)) || !File.Exists(updaterPath) || ProcessEx.IsRunning(Path.GetFileNameWithoutExtension(updaterPath))) { return; } var dataDir = PathEx.Combine(PathEx.LocalDir, "Data"); var defCursorDir = PathEx.Combine(appDir, "Cursors"); var cursorDir = PathEx.Combine(dataDir, "Cursors"); var dirMap = new Dictionary <string, string> { { "%LocalAppData%\\YoloMouse", dataDir }, { defCursorDir, cursorDir } }; Helper.ApplicationStart(updaterPath, "/silent", null); if (!File.Exists(appPath)) { var updIniPath = Path.ChangeExtension(updaterPath, ".ini"); if (!string.IsNullOrEmpty(updIniPath) && File.Exists(updIniPath)) { File.Delete(updIniPath); } return; } var cfgPath = Path.Combine(dataDir, "Settings.ini"); if (!File.Exists(cfgPath)) { if (!Directory.Exists(dataDir)) { Directory.CreateDirectory(dataDir); } File.WriteAllText(cfgPath, Resources.DefaultSettings); } if (Directory.Exists(defCursorDir)) { Data.DirCopy(defCursorDir, cursorDir, true, true); try { Directory.Delete(defCursorDir); } catch (Exception ex) { Log.Write(ex); ProcessEx.SendHelper.WaitForExitThenDelete(defCursorDir, ProcessEx.CurrentName, Elevation.IsAdministrator); } } Helper.DirectoryForwarding(Helper.Options.Start, dirMap); Helper.ApplicationStart(appPath, EnvironmentEx.CommandLine(false), false); Helper.DirectoryForwarding(Helper.Options.Exit, dirMap); } }
private static void Main() { Log.AllowLogging(); using (new Mutex(true, ProcessEx.CurrentName, out bool newInstance)) { var appDir = PathEx.Combine(PathEx.LocalDir, "App\\Gyazo"); if (!Directory.Exists(appDir)) { return; } var appPath = Path.Combine(appDir, "Gyazowin.exe"); var trayMode = Environment.CommandLine.ContainsEx("/Tray") || Ini.Read("Settings", "Tray", false, Path.ChangeExtension(PathEx.LocalPath, ".ini")); if (!newInstance) { if (trayMode) { ProcessEx.Start(appPath, EnvironmentEx.CommandLine(false)); } return; } if (trayMode) { appPath = Path.Combine(appDir, "GyStation.exe"); } var updaterPath = Path.Combine(appDir, "GyazoUpdater.exe"); if (ProcessEx.IsRunning(Path.GetFileNameWithoutExtension(appPath)) || !File.Exists(updaterPath) || ProcessEx.IsRunning(Path.GetFileNameWithoutExtension(updaterPath))) { return; } Helper.ApplicationStart(updaterPath, "/silent", null); if (!File.Exists(appPath)) { var updIniPath = Path.ChangeExtension(updaterPath, ".ini"); if (!string.IsNullOrEmpty(updIniPath) && File.Exists(updIniPath)) { File.Delete(updIniPath); } return; } var dirMap = new Dictionary <string, string> { { "%AppData%\\Gyazo", "%CurDir%\\Data" } }; var regKeys = new[] { "HKCU\\Software\\Gyazo" }; Helper.DirectoryForwarding(Helper.Options.Start, dirMap); Helper.RegForwarding(Helper.Options.Start, regKeys); Helper.ApplicationStart(appPath, EnvironmentEx.CommandLine(false), false); Helper.DirectoryForwarding(Helper.Options.Exit, dirMap); Helper.RegForwarding(Helper.Options.Exit, regKeys); } }
private static void Main() { Log.AllowLogging(); using (new Mutex(true, ProcessEx.CurrentName, out bool newInstance)) { var appDir = PathEx.Combine(PathEx.LocalDir, "App\\FurMark"); if (!Directory.Exists(appDir)) { return; } var appPath = Path.Combine(appDir, "FurMark.exe"); if (!newInstance) { ProcessEx.Start(appPath, EnvironmentEx.CommandLine(false), Elevation.IsAdministrator); return; } var updaterPath = PathEx.Combine(appDir, "FurMarkUpdater.exe"); if (ProcessEx.IsRunning(Path.GetFileNameWithoutExtension(appPath)) || !File.Exists(updaterPath) || ProcessEx.IsRunning(Path.GetFileNameWithoutExtension(updaterPath))) { return; } var dataDir = PathEx.Combine(PathEx.LocalDir, "Data"); var dirMap = new Dictionary <string, string> { { PathEx.Combine(appDir, "screenshots"), PathEx.Combine(dataDir, "screenshots") } }; var fileMap = new Dictionary <string, string> { { PathEx.Combine(appDir, "furmark-gpu-monitoring.csv"), PathEx.Combine(dataDir, "furmark-gpu-monitoring.csv") }, { PathEx.Combine(appDir, "furmark-gpu-monitoring.xml"), PathEx.Combine(dataDir, "furmark-gpu-monitoring.xml") }, { PathEx.Combine(appDir, "startup_options.xml"), PathEx.Combine(dataDir, "startup_options.xml") } }; try { foreach (var file in Directory.EnumerateFiles(appDir, "*.log", SearchOption.TopDirectoryOnly)) { var name = Path.GetFileName(file); fileMap.Add(file, PathEx.Combine(dataDir, name)); } } catch (Exception ex) { Log.Write(ex); } Helper.DirectoryForwarding(Helper.Options.Start, dirMap); Helper.FileForwarding(Helper.Options.Start, fileMap, true); Helper.ApplicationStart(updaterPath, "/silent", null); if (!File.Exists(appPath)) { var updIniPath = Path.ChangeExtension(updaterPath, ".ini"); if (!string.IsNullOrEmpty(updIniPath) && File.Exists(updIniPath)) { File.Delete(updIniPath); } Helper.DirectoryForwarding(Helper.Options.Exit, dirMap); Helper.FileForwarding(Helper.Options.Exit, fileMap, true); return; } Helper.ApplicationStart(appPath, EnvironmentEx.CommandLine(false), false); Helper.DirectoryForwarding(Helper.Options.Exit, dirMap); Helper.FileForwarding(Helper.Options.Exit, fileMap, true); } }
private static void Main() { Log.AllowLogging(); using (new Mutex(true, ProcessEx.CurrentName, out bool newInstance)) { var appDir = PathEx.Combine(PathEx.LocalDir, "App", Environment.Is64BitOperatingSystem ? "p95win64" : "p95win32"); if (!Directory.Exists(appDir)) { return; } var appPath = Path.Combine(appDir, "prime95.exe"); if (!newInstance) { ProcessEx.Start(appPath, EnvironmentEx.CommandLine(false)); return; } #if LEGACY if (!File.Exists(appPath) || ProcessEx.IsRunning(Path.GetFileNameWithoutExtension(appPath))) { return; } #else var updaterPath = Path.Combine(appDir, Environment.Is64BitOperatingSystem ? "Prime95Updater64.exe" : "Prime95Updater.exe"); if (ProcessEx.IsRunning(Path.GetFileNameWithoutExtension(appPath)) || !File.Exists(updaterPath) || ProcessEx.IsRunning(Path.GetFileNameWithoutExtension(updaterPath))) { return; } Helper.ApplicationStart(updaterPath, "/silent", null); if (!File.Exists(appPath)) { var updIniPath = Path.ChangeExtension(updaterPath, ".ini"); if (!string.IsNullOrEmpty(updIniPath) && File.Exists(updIniPath)) { File.Delete(updIniPath); } return; } #endif try { var dataDir = PathEx.Combine(PathEx.LocalDir, "Data"); var cfgPath = PathEx.Combine(appDir, "prime.txt"); if (!File.Exists(cfgPath)) { File.Create(cfgPath).Close(); } if (!File.ReadAllText(cfgPath).EqualsEx(dataDir)) { File.WriteAllText(cfgPath, $"WorkingDir={dataDir}"); } cfgPath = PathEx.Combine(dataDir, "prime.txt"); if (!File.Exists(cfgPath)) { if (!Directory.Exists(dataDir)) { Directory.CreateDirectory(dataDir); } File.WriteAllText(cfgPath, "TrayIcon=0"); } } catch (Exception ex) { Log.Write(ex); } Helper.ApplicationStart(appPath, EnvironmentEx.CommandLine(false), ProcessWindowStyle.Maximized, false); } }
private static void Main() { Log.AllowLogging(); using (new Mutex(true, ProcessEx.CurrentName, out bool newInstance)) { #if x86 var curPath64 = PathEx.Combine(PathEx.LocalDir, "CheatEngine64Portable.exe"); if (Environment.Is64BitOperatingSystem) { if (!File.Exists(curPath64)) { return; } ProcessEx.Start(curPath64, EnvironmentEx.CommandLine(false)); return; } #endif var appDir = PathEx.Combine(PathEx.LocalDir, "App\\CheatEngine"); var appPath = PathEx.Combine(appDir, "Cheat Engine.exe"); if (!newInstance) { if (!File.Exists(appPath)) { return; } ProcessEx.Start(appDir, true); return; } var updaterPath = PathEx.Combine(appDir, "CheatEngineUpdater.exe"); if (!File.Exists(updaterPath)) { return; } Helper.ApplicationStart(updaterPath, "/silent", null); if (!File.Exists(appPath)) { var updIniPath = Path.ChangeExtension(updaterPath, ".ini"); if (!string.IsNullOrEmpty(updIniPath) && File.Exists(updIniPath)) { File.Delete(updIniPath); } return; } var dataDir = PathEx.Combine(PathEx.LocalDir, "Data"); var tablesDir = PathEx.Combine(dataDir, "My Cheat Tables"); var dirMap = new Dictionary <string, string> { { "%MyDocuments%\\My Cheat Tables", tablesDir } }; var regKeys = new[] { "HKCU\\Software\\Cheat Engine" }; Helper.DirectoryForwarding(Helper.Options.Start, dirMap); Helper.RegForwarding(Helper.Options.Start, regKeys); Reg.Write(regKeys.First(), "Initial tables dir", tablesDir, RegistryValueKind.String); Helper.ApplicationStart(appPath, EnvironmentEx.CommandLine(false), Elevation.IsAdministrator); Helper.DirectoryForwarding(Helper.Options.Exit, dirMap); Helper.RegForwarding(Helper.Options.Exit, regKeys); } }
private static void Main() { Log.AllowLogging(); #if x86 var curPath64 = PathEx.Combine(PathEx.LocalDir, "VLC64Portable.exe"); if (Environment.Is64BitOperatingSystem && File.Exists(curPath64)) { ProcessEx.Start(curPath64, EnvironmentEx.CommandLine()); return; } var appDir = PathEx.Combine(PathEx.LocalDir, "App\\vlc"); var updaterPath = PathEx.Combine(appDir, "VLCUpdater.exe"); #else var appDir = PathEx.Combine(PathEx.LocalDir, "App\\vlc64"); var updaterPath = PathEx.Combine(appDir, "VLCUpdater64.exe"); #endif if (!File.Exists(updaterPath) || ProcessEx.IsRunning(Path.GetFileNameWithoutExtension(updaterPath))) { return; } using (new Mutex(true, ProcessEx.CurrentName, out bool newInstance)) { var appPath = PathEx.Combine(appDir, "vlc.exe"); if (!newInstance) { ProcessEx.Start(appPath, EnvironmentEx.CommandLine()); return; } if (ProcessEx.IsRunning(Path.GetFileNameWithoutExtension(appPath))) { return; } var dirMap = new Dictionary <string, string> { { "%AppData%\\vlc", "%CurDir%\\Data" } }; Helper.ApplicationStart(updaterPath, "/silent", null); if (!File.Exists(appPath)) { var updIniPath = Path.ChangeExtension(updaterPath, ".ini"); if (!string.IsNullOrEmpty(updIniPath) && File.Exists(updIniPath)) { File.Delete(updIniPath); } return; } Helper.DirectoryForwarding(Helper.Options.Start, dirMap); Helper.ApplicationStart(appPath, $"{EnvironmentEx.CommandLine()} --no-plugins-cache"); Helper.DirectoryForwarding(Helper.Options.Exit, dirMap); } }
public static void RedistHandling(Options options, params EnvironmentEx.Redist.Flags[] versions) { var dict = new Dictionary <EnvironmentEx.Redist.Flags, Dictionary <int, List <int> > >(); foreach (var version in versions) { if (!dict.ContainsKey(version)) { dict.Add(version, new Dictionary <int, List <int> >()); } switch (version) { case EnvironmentEx.Redist.Flags.VC2005X86: if (!dict[version].ContainsKey(2005)) { dict[version].Add(2005, new List <int>()); } dict[version][2005].Add(86); break; case EnvironmentEx.Redist.Flags.VC2005X64: if (!dict[version].ContainsKey(2005)) { dict[version].Add(2005, new List <int>()); } dict[version][2005].Add(64); break; case EnvironmentEx.Redist.Flags.VC2008X86: if (!dict[version].ContainsKey(2008)) { dict[version].Add(2008, new List <int>()); } dict[version][2008].Add(86); break; case EnvironmentEx.Redist.Flags.VC2008X64: if (!dict[version].ContainsKey(2008)) { dict[version].Add(2008, new List <int>()); } dict[version][2008].Add(64); break; case EnvironmentEx.Redist.Flags.VC2010X86: if (!dict[version].ContainsKey(2010)) { dict[version].Add(2010, new List <int>()); } dict[version][2010].Add(86); break; case EnvironmentEx.Redist.Flags.VC2010X64: if (!dict[version].ContainsKey(2010)) { dict[version].Add(2010, new List <int>()); } dict[version][2010].Add(64); break; case EnvironmentEx.Redist.Flags.VC2012X86: if (!dict[version].ContainsKey(2012)) { dict[version].Add(2012, new List <int>()); } dict[version][2012].Add(86); break; case EnvironmentEx.Redist.Flags.VC2012X64: if (!dict[version].ContainsKey(2012)) { dict[version].Add(2012, new List <int>()); } dict[version][2012].Add(64); break; case EnvironmentEx.Redist.Flags.VC2013X86: if (!dict[version].ContainsKey(2013)) { dict[version].Add(2013, new List <int>()); } dict[version][2013].Add(86); break; case EnvironmentEx.Redist.Flags.VC2013X64: if (!dict[version].ContainsKey(2013)) { dict[version].Add(2013, new List <int>()); } dict[version][2013].Add(64); break; case EnvironmentEx.Redist.Flags.VC2015X86: if (!dict[version].ContainsKey(2015)) { dict[version].Add(2015, new List <int>()); } dict[version][2015].Add(86); break; case EnvironmentEx.Redist.Flags.VC2015X64: if (!dict[version].ContainsKey(2015)) { dict[version].Add(2015, new List <int>()); } dict[version][2015].Add(64); break; case EnvironmentEx.Redist.Flags.VC2017X86: if (!dict[version].ContainsKey(2017)) { dict[version].Add(2017, new List <int>()); } dict[version][2017].Add(86); break; case EnvironmentEx.Redist.Flags.VC2017X64: if (!dict[version].ContainsKey(2017)) { dict[version].Add(2017, new List <int>()); } dict[version][2017].Add(64); break; default: return; } } foreach (var data in dict) { var version = data.Key; foreach (var vars in data.Value) { var year = vars.Key; foreach (var arch in vars.Value) { var path = PathEx.Combine(PathEx.LocalDir, $"_CommonRedist\\vcredist\\{year}\\vcredist_x{arch}.exe"); if (!File.Exists(path)) { return; } var iniPath = Path.ChangeExtension(PathEx.LocalPath, ".ini"); switch (options) { case Options.Exit: if (Ini.ReadDirect("Redist", version.ToString(), iniPath).EqualsEx("True")) { return; } using (var p = ProcessEx.Start(path, "/q /uninstall /norestart", Elevation.IsAdministrator, false)) if (p?.HasExited == false) { p.WaitForExit(); } break; default: if (Ini.ReadDirect("Redist", version.ToString(), iniPath).EqualsEx("False")) { Elevation.RestartAsAdministrator(EnvironmentEx.CommandLine(false)); } if (EnvironmentEx.Redist.IsInstalled(version)) { Ini.WriteDirect("Redist", version.ToString(), true, iniPath); break; } var info = FileVersionInfo.GetVersionInfo(PathEx.LocalPath); if (!Ini.ReadDirect("Redist", version.ToString(), iniPath).EqualsEx("True", "False")) { MessageBoxEx.TopMost = true; MessageBoxEx.ButtonText.OverrideEnabled = true; MessageBoxEx.ButtonText.Yes = "&Yes"; MessageBoxEx.ButtonText.No = "&No"; MessageBoxEx.ButtonText.Cancel = "&Cancel"; var msg = $"Microsoft Visual C++ {year} Redistributable Package (x{arch}) is required to run this porgram.{Environment.NewLine}{Environment.NewLine}Would you like to permanently install this package (yes) or temporarily (no)?"; var result = MessageBoxEx.Show(msg, info.FileDescription, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (result == DialogResult.Cancel) { RedistHandling(Options.Exit, versions); Environment.Exit(Environment.ExitCode); } Ini.WriteDirect("Redist", version.ToString(), result == DialogResult.Yes, iniPath); if (result != DialogResult.Yes) { Elevation.RestartAsAdministrator(EnvironmentEx.CommandLine(false)); } } var notifyBox = new NotifyBox(); notifyBox.Show($"Microsoft Visual C++ {year} Redistributable Package (x{arch}) has been initialized . . .", info.FileDescription, NotifyBox.NotifyBoxStartPosition.Center); using (var p = ProcessEx.Start(path, "/q /norestart", Elevation.IsAdministrator, false)) if (p?.HasExited == false) { p.WaitForExit(); } notifyBox.Close(); if (!EnvironmentEx.Redist.IsInstalled(version)) { Environment.ExitCode = 1; Environment.Exit(Environment.ExitCode); } break; } } } } }
private static void Main() { Log.AllowLogging(); using (new Mutex(true, ProcessEx.CurrentName, out bool newInstance)) { if (!newInstance) { return; } var appDir = PathEx.Combine(PathEx.LocalDir, "App\\cinebench64"); var appPath = PathEx.Combine(appDir, "CINEBENCH Windows 64 Bit.exe"); var updaterPath = Path.Combine(appDir, "CinebenchUpdater64.exe"); if (ProcessEx.IsRunning(Path.GetFileNameWithoutExtension(appPath)) || !File.Exists(updaterPath) || ProcessEx.IsRunning(Path.GetFileNameWithoutExtension(updaterPath))) { return; } var appDataDir = PathEx.Combine("%AppData%\\MAXON"); var dataDir = PathEx.Combine("%CurDir%\\Data"); RemoveLongPaths(appDir); RemoveLongPaths(appDataDir); RemoveLongPaths(dataDir); var dirMap = new Dictionary <string, string> { { appDataDir, dataDir }, { PathEx.Combine(appDir, "cb_ranking"), PathEx.Combine(dataDir, "cb_ranking") } }; Helper.DirectoryForwarding(Helper.Options.Start, dirMap); Helper.ApplicationStart(updaterPath, "/silent", null); if (!File.Exists(appPath)) { var updIniPath = Path.ChangeExtension(updaterPath, ".ini"); if (!string.IsNullOrEmpty(updIniPath) && File.Exists(updIniPath)) { File.Delete(updIniPath); } RemoveLongPaths(appDir); RemoveLongPaths(appDataDir); RemoveLongPaths(dataDir); Helper.DirectoryForwarding(Helper.Options.Exit, dirMap); return; } Helper.ApplicationStart(appPath, EnvironmentEx.CommandLine(false), false); RemoveLongPaths(appDir); RemoveLongPaths(appDataDir); RemoveLongPaths(dataDir); Helper.DirectoryForwarding(Helper.Options.Exit, dirMap); } }
private static void Main() { Log.AllowLogging(); var appDir = PathEx.Combine(PathEx.LocalDir, "App\\jd2"); var appPath = Path.Combine(appDir, "JDownloader.jar"); if (!File.Exists(appPath)) { MessageBox.Show(@"JDownloader 2 not found!", @"JDownloader 2 Portable", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } var iniPath = Path.ChangeExtension(PathEx.LocalPath, ".ini"); if (!File.Exists(iniPath)) { Ini.WriteDirect("Associations", "FileTypes", "ccf,dlc,jdc,rsdf,sft", iniPath); } Helper.FindJava(out string javaPath, iniPath); using (new Mutex(true, ProcessEx.CurrentName, out bool newInstance)) { var cmdLine = $"-jar \"{appPath}\" {EnvironmentEx.CommandLine(false)}".Trim(); if (!newInstance) { ProcessEx.Start(javaPath, appDir, cmdLine); return; } try { DataHelper(); using (var p = ProcessEx.Start(javaPath, appDir, cmdLine, false, false)) if (p?.HasExited == false) { p.WaitForExit(); } Recheck: var appName = Path.GetFileNameWithoutExtension(javaPath); foreach (var p in ProcessEx.GetInstances(appName)) { var wasRunning = false; bool isRunning; do { isRunning = p?.GetCommandLine()?.ContainsEx(appDir) == true; if (p?.HasExited == false) { p.WaitForExit(); } if (!wasRunning && isRunning) { wasRunning = true; } Thread.Sleep(200); }while (isRunning); if (!wasRunning) { continue; } Thread.Sleep(250); goto Recheck; } var usageDir = PathEx.Combine("%UserProfile%\\.oracle_jre_usage"); if (Directory.Exists(usageDir)) { Directory.Delete(usageDir); } } catch (Exception ex) { Log.Write(ex); } } }
private static void Main() { Log.AllowLogging(); using (new Mutex(true, ProcessEx.CurrentName, out bool newInstance)) { var appDir = PathEx.Combine(PathEx.LocalDir, "App\\Origin"); var appPath = Path.Combine(appDir, "Origin.exe"); if (!newInstance) { ProcessEx.Start(appPath, EnvironmentEx.CommandLine(false)); return; } #if x86 if (Environment.Is64BitOperatingSystem) { var curPath64 = PathEx.Combine(PathEx.LocalDir, $"{Path.GetFileNameWithoutExtension(PathEx.LocalPath)}64.exe"); ProcessEx.Start(curPath64, EnvironmentEx.CommandLine(false)); return; } #endif if (IsRunning(appDir)) { CloseAll(appDir); } var dataDir = PathEx.Combine(PathEx.LocalDir, "Data"); if (IsRunning(dataDir)) { CloseAll(dataDir); } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Helper.RedistHandling(Helper.Options.Start, EnvironmentEx.Redist.Flags.VC2010X86, EnvironmentEx.Redist.Flags.VC2013X86 #if !x86 , EnvironmentEx.Redist.Flags.VC2010X64, EnvironmentEx.Redist.Flags.VC2013X64 #endif ); var iniPath = Path.ChangeExtension(PathEx.LocalPath, ".ini"); if (!File.Exists(iniPath)) { Ini.WriteDirect("Settings", "Tray", false, iniPath); } var dirMap = new Dictionary <string, string> { { "%SystemDrive%\\temp", "%CurDir%\\Data\\Temp" }, { "%CommonProgramFiles(x86)%\\EAInstaller", "%CurDir%\\App\\Common\\EAInstaller" }, { "%AppData%\\EA Games", "%CurDir%\\Data\\AppData\\Roaming\\EA Games" }, { "%AppData%\\Electronic Arts", "%CurDir%\\Data\\AppData\\Roaming\\Electronic Arts" }, { "%AppData%\\Origin", "%CurDir%\\Data\\AppData\\Roaming\\Origin" }, { "%LocalAppData%\\EA Games", "%CurDir%\\Data\\AppData\\Local\\EA Games" }, { "%LocalAppData%\\Electronic Arts", "%CurDir%\\Data\\AppData\\Local\\Electronic Arts" }, { "%LocalAppData%\\Origin", "%CurDir%\\Data\\AppData\\Local\\Origin" }, { "%ProgramData%\\EA Games", "%CurDir%\\Data\\ProgramData\\EA Games" }, { "%ProgramData%\\Electronic Arts", "%CurDir%\\Data\\ProgramData\\Electronic Arts" }, { "%ProgramData%\\Origin", "%CurDir%\\Data\\ProgramData\\Origin" }, { "%UserProfile%\\.Origin", "%CurDir%\\Data\\Temp" } }; Helper.DirectoryForwarding(Helper.Options.Start, dirMap); var regKeys = new[] { "HKCR\\origin", "HKCR\\origin2", "HKCU\\Software\\EA Games", "HKCU\\Software\\Electronic Arts", "HKLM\\SOFTWARE\\EA Games", "HKLM\\SOFTWARE\\Electronic Arts", "HKLM\\SOFTWARE\\Origin", #if x86 "HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Origin", #else "HKLM\\SOFTWARE\\Wow6432Node\\EA Games", "HKLM\\SOFTWARE\\Wow6432Node\\Electronic Arts", "HKLM\\SOFTWARE\\Wow6432Node\\Origin", "HKLM\\SOFTWARE\\Wow6432Node\\Origin Games", "HKLM\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Origin" #endif }; Helper.RegForwarding(Helper.Options.Start, regKeys); var key = "HKCR\\origin"; Reg.Write(key, null, $"\"{appPath}\" \"%1\""); key = "HKCR\\origin2"; Reg.Write(key, null, $"\"{appPath}\" \"%1\""); #if x86 key = "HKLM\\SOFTWARE\\Electronic Arts\\EA Core"; #else key = "HKLM\\SOFTWARE\\Wow6432Node\\Electronic Arts\\EA Core"; #endif Reg.Write(key, "ClientAccessDLLPath", Path.Combine(appDir, "LegacyPM\\CmdPortalClient.dll")); Reg.Write(key, "ClientPath", Path.Combine(appDir, "LegacyPM\\OriginLegacyCLI.dll")); Reg.Write(key, "EADM6InstallDir", appDir); #if x86 key = "HKLM\\SOFTWARE\\Electronic Arts\\EADM"; #else key = "HKLM\\SOFTWARE\\Wow6432Node\\Electronic Arts\\EADM"; #endif Reg.Write(key, "ClientPath", appPath); #if x86 key = "HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Origin"; #else key = "HKLM\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Origin"; #endif Reg.Write(key, "DisplayIcon", PathEx.Combine(appDir, "OriginUninstall.exe")); Reg.Write(key, "InstallLocation", appDir); Reg.Write(key, "UninstallString", PathEx.Combine(appDir, "OriginUninstall.exe")); var regPath = Path.Combine(dataDir, "settings.reg"); if (!File.Exists(regPath)) { string version; try { version = FileVersionInfo.GetVersionInfo(appPath).FileVersion; if (version.Contains(',')) { version = version.Split(',').Select(c => c.Trim()).Join('.'); } } catch { version = "0.0.0.0"; } #if x86 key = "HKLM\\SOFTWARE\\Electronic Arts\\EA Core"; #else key = "HKLM\\SOFTWARE\\Wow6432Node\\Electronic Arts\\EA Core"; #endif Reg.Write(key, "ClientVersion", "7.0.0.1"); Reg.Write(key, "EADM6Version", "7.0.0.1"); #if x86 key = "HKLM\\SOFTWARE\\Electronic Arts\\EADM"; #else key = "HKLM\\SOFTWARE\\Wow6432Node\\Electronic Arts\\EADM"; #endif Reg.Write(key, "ClientVersion", version); #if x86 key = "HKLM\\SOFTWARE\\Origin"; #else key = "HKLM\\SOFTWARE\\Wow6432Node\\Origin"; #endif Reg.Write(key, "AutopatchGlobal", false, RegistryValueKind.String); Reg.Write(key, "Autoupdate", false, RegistryValueKind.String); Reg.Write(key, "ClientVersion", version); Reg.Write(key, "InstallSuccesfull", true, RegistryValueKind.String); Reg.Write(key, "IsBeta", false, RegistryValueKind.String); Reg.Write(key, "Launch", 0x014629dd, RegistryValueKind.String); Reg.Write(key, "ShowDirPage", true, RegistryValueKind.String); Reg.Write(key, "TelemOO", false, RegistryValueKind.String); #if x86 key = "HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Origin"; #else key = "HKLM\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Origin"; #endif Reg.Write(key, "DisplayName", "Origin"); Reg.Write(key, "DisplayVersion", version); Reg.Write(key, "EstimatedSize", 0x0004d338, RegistryValueKind.DWord); Reg.Write(key, "NoModify", 0x00000001, RegistryValueKind.DWord); Reg.Write(key, "NoRepair", 0x00000001, RegistryValueKind.DWord); Reg.Write(key, "OriginUninstall.exe", true, RegistryValueKind.String); Reg.Write(key, "Publisher", "Electronic Arts, Inc."); Reg.Write(key, "sEstimatedSize2", 0x00000000, RegistryValueKind.DWord); Reg.Write(key, "URLInfoAbout", "http://www.ea.com"); } using (var p = ProcessEx.Start(appPath, EnvironmentEx.CommandLine(false), Elevation.IsAdministrator, Ini.ReadDirect("Settings", "Tray").EqualsEx("True") ? ProcessWindowStyle.Minimized : ProcessWindowStyle.Normal, false)) if (p?.HasExited == false) { p.WaitForExit(); } var dirs = new[] { appDir, dataDir }; Recheck: foreach (var dir in dirs) { var wasRunning = false; while (IsRunning(dir)) { if (!wasRunning) { wasRunning = true; } Thread.Sleep(200); } if (!wasRunning) { continue; } Thread.Sleep(250); goto Recheck; } CloseServices(); Helper.DirectoryForwarding(Helper.Options.Exit, dirMap); Helper.RegForwarding(Helper.Options.Exit, regKeys); Helper.RedistHandling(Helper.Options.Exit, EnvironmentEx.Redist.Flags.VC2010X86, EnvironmentEx.Redist.Flags.VC2013X86 #if !x86 , EnvironmentEx.Redist.Flags.VC2010X64, EnvironmentEx.Redist.Flags.VC2013X64 #endif ); try { var qtWebEngineCacheDir = PathEx.Combine("%UserProfile%\\.QtWebEngineProcess"); if (Directory.Exists(qtWebEngineCacheDir)) { Directory.Delete(qtWebEngineCacheDir, true); } } catch (Exception ex) { Log.Write(ex); } } }
private static void Main() { Log.AllowLogging(); using (new Mutex(true, ProcessEx.CurrentName, out bool newInstance)) { var appDir = PathEx.Combine(PathEx.LocalDir, "App\\HeidiSQL"); if (!Directory.Exists(appDir)) { return; } var appPath = Path.Combine(appDir, "heidisql.exe"); if (!newInstance) { ProcessEx.Start(appPath, EnvironmentEx.CommandLine(false)); return; } var updaterPath = Path.Combine(appDir, "HeidiSQLUpdater.exe"); if (ProcessEx.IsRunning(Path.GetFileNameWithoutExtension(appPath)) || !File.Exists(updaterPath) || ProcessEx.IsRunning(Path.GetFileNameWithoutExtension(updaterPath))) { return; } var dataDir = PathEx.Combine(PathEx.LocalDir, "Data"); var dirMap = new Dictionary <string, string> { { PathEx.Combine("%AppData%\\HeidiSQL"), PathEx.Combine(dataDir, "HeidiSQL") } }; var fileMap = new Dictionary <string, string> { { PathEx.Combine(appDir, "portable_settings.txt"), PathEx.Combine(dataDir, "portable_settings.txt") } }; Helper.ApplicationStart(updaterPath, "/silent", null); if (!File.Exists(appPath)) { var updIniPath = Path.ChangeExtension(updaterPath, ".ini"); if (!string.IsNullOrEmpty(updIniPath) && File.Exists(updIniPath)) { File.Delete(updIniPath); } return; } Helper.DirectoryForwarding(Helper.Options.Start, dirMap); Helper.FileForwarding(Helper.Options.Start, fileMap, true); Helper.ApplicationStart(appPath, EnvironmentEx.CommandLine(false), false); Helper.DirectoryForwarding(Helper.Options.Exit, dirMap); Helper.FileForwarding(Helper.Options.Exit, fileMap, true); } }
private static void Main() { Log.AllowLogging(); using (new Mutex(true, ProcessEx.CurrentName, out bool newInstance)) { if (!newInstance) { return; } var appDir = PathEx.Combine(PathEx.LocalDir, "App\\TeamViewer"); var appPath = Path.Combine(appDir, "TeamViewer.exe"); var updaterPath = Path.Combine(appDir, "TeamViewerUpdater.exe"); var processes = new[] { "TeamViewer", "TeamViewer_Desktop", "tv_w32", "tv_x64", "TeamViewerUpdater" }; if (!File.Exists(updaterPath) || processes.Any(name => ProcessEx.IsRunning(name))) { return; } Helper.ApplicationStart(updaterPath, "/silent", null); if (!File.Exists(appPath)) { var updIniPath = Path.ChangeExtension(updaterPath, ".ini"); if (!string.IsNullOrEmpty(updIniPath) && File.Exists(updIniPath)) { File.Delete(updIniPath); } return; } var dataDir = PathEx.Combine(PathEx.LocalDir, "Data"); if (!Directory.Exists(dataDir)) { Directory.CreateDirectory(dataDir); } var fileMap = new Dictionary <string, string> { { "%CurDir%\\App\\TeamViewer\\TeamViewer.ini", "%CurDir%\\Data\\config.ini" }, { "%CurDir%\\App\\TeamViewer\\tv.ini", "%CurDir%\\Data\\settings.ini" } }; var configPath = PathEx.Combine(fileMap.First().Key); if (File.Exists(configPath)) { File.Delete(configPath); } configPath = PathEx.Combine(fileMap.First().Value); if (!File.Exists(configPath)) { File.WriteAllText(configPath, Resources.config); } Ini.WriteDirect("Settings", "nosave", 1, configPath); Ini.WriteDirect("Settings", "importsettings", 1, configPath); var settingsPath = PathEx.Combine(fileMap.Last().Key); if (File.Exists(settingsPath)) { File.Delete(settingsPath); } settingsPath = PathEx.Combine(fileMap.Last().Value); if (!File.Exists(settingsPath)) { File.WriteAllText(settingsPath, Resources.settings); } Helper.FileForwarding(Helper.Options.Start, fileMap); var dirMap = new Dictionary <string, string> { { "%AppData%\\TeamViewer", "%CurDir%\\Data\\logs" } }; Helper.DirectoryForwarding(Helper.Options.Start, dirMap); const string regKey = "HKLM\\SOFTWARE\\TeamViewer"; Helper.RegForwarding(Helper.Options.Start, regKey); Helper.ApplicationStart(appPath, EnvironmentEx.CommandLine(false)); Helper.FileForwarding(Helper.Options.Exit, fileMap); Helper.DirectoryForwarding(Helper.Options.Exit, dirMap); Helper.RegForwarding(Helper.Options.Exit, regKey); } }
private static void Main() { Log.AllowLogging(); using (new Mutex(true, ProcessEx.CurrentName, out bool newInstance)) { if (!newInstance) { return; } var appDir = PathEx.Combine(PathEx.LocalDir, "App\\hwmon"); if (!Directory.Exists(appDir)) { return; } var appPath = Path.Combine(appDir, Environment.CommandLine.ContainsEx("/Tray") ? "HwMonTray.exe" : (Environment.Is64BitOperatingSystem ? "HWMonitor_x64.exe" : "HWMonitor_x32.exe")); var updaterPath = Path.Combine(appDir, "HWMonitorUpdater.exe"); if (ProcessEx.IsRunning(Path.GetFileNameWithoutExtension(appPath)) || !File.Exists(updaterPath) || ProcessEx.IsRunning(Path.GetFileNameWithoutExtension(updaterPath))) { return; } Helper.ApplicationStart(updaterPath, "/silent", null); if (!File.Exists(appPath)) { var updIniPath = Path.ChangeExtension(updaterPath, ".ini"); if (!string.IsNullOrEmpty(updIniPath) && File.Exists(updIniPath)) { File.Delete(updIniPath); } return; } const string iniPath = "%CurDir%\\Data\\HWMonitorW.ini"; var iniMap = new Dictionary <string, Dictionary <string, string> > { { "HWMonitor", new Dictionary <string, string> { { "UPDATES", "0" } } } }; var fileMap = new Dictionary <string, string> { { "%CurDir%\\App\\hwmon\\HWMonitorW.ini", "%CurDir%\\Data\\HWMonitorW.ini" } }; Helper.ConfigOverwrite(iniMap, iniPath); Helper.FileForwarding(Helper.Options.Start, fileMap, true); Helper.ApplicationStart(appPath, EnvironmentEx.CommandLine(false), false); Helper.FileForwarding(Helper.Options.Exit, fileMap, true); } }
private static void Main() { Log.AllowLogging(); #if x86 var curPath64 = PathEx.Combine(PathEx.LocalDir, "OBSStudio64Portable.exe"); if (Environment.Is64BitOperatingSystem && File.Exists(curPath64)) { ProcessEx.Start(curPath64, EnvironmentEx.CommandLine(false)); return; } var appPath = PathEx.Combine(PathEx.LocalDir, "App\\bin\\32bit\\obs32.exe"); var redPath = PathEx.Combine(PathEx.LocalDir, "App\\bin\\64bit\\obs64.exe"); #else var appPath = PathEx.Combine(PathEx.LocalDir, "App\\bin\\64bit\\obs64.exe"); var redPath = PathEx.Combine(PathEx.LocalDir, "App\\bin\\32bit\\obs32.exe"); #endif if (!File.Exists(appPath) || ProcessEx.IsRunning(Path.GetFileNameWithoutExtension(appPath)) || ProcessEx.IsRunning(Path.GetFileNameWithoutExtension(redPath))) { return; } bool newInstance; using (new Mutex(true, ProcessEx.CurrentName, out newInstance)) { if (!newInstance) { return; } var dirMap = new Dictionary <string, string> { { "%AppData%\\obs-studio", "%CurDir%\\Data" } }; Helper.DirectoryForwarding(Helper.Options.Start, dirMap); Helper.ApplicationStart(appPath, EnvironmentEx.CommandLine(false)); var names = new[] { Path.GetFileNameWithoutExtension(appPath), Path.GetFileNameWithoutExtension(redPath) }; Recheck: foreach (var name in names) { var wasRunning = false; while (ProcessEx.IsRunning(name) || ProcessEx.IsRunning("consent") || WinApi.NativeHelper.FindWindowByCaption("OBS Studio Update") != IntPtr.Zero) { if (!wasRunning) { wasRunning = true; } Thread.Sleep(200); } if (!wasRunning) { continue; } Thread.Sleep(250); goto Recheck; } Helper.DirectoryForwarding(Helper.Options.Exit, dirMap); } }
private static void Main() { Log.AllowLogging(); using (new Mutex(true, ProcessEx.CurrentName, out bool newInstance)) { if (!newInstance) { return; } #if x86 var curPath64 = PathEx.Combine(PathEx.LocalDir, "CDBurnerXP64Portable.exe"); if (Environment.Is64BitOperatingSystem && File.Exists(curPath64)) { ProcessEx.Start(curPath64, EnvironmentEx.CommandLine(false)); return; } var appDir = PathEx.Combine(PathEx.LocalDir, "App\\CDBurnerXP"); #else var appDir = PathEx.Combine(PathEx.LocalDir, "App\\CDBurnerXP64"); #endif if (!Directory.Exists(appDir)) { return; } var appPath = Path.Combine(appDir, "cdbxpp.exe"); #if x86 var updaterPath = PathEx.Combine(appDir, "CDBurnerXPUpdater.exe"); #else var updaterPath = PathEx.Combine(appDir, "CDBurnerXPUpdater64.exe"); #endif if (ProcessEx.IsRunning(Path.GetFileNameWithoutExtension(appPath)) || !File.Exists(updaterPath) || ProcessEx.IsRunning(Path.GetFileNameWithoutExtension(updaterPath))) { return; } var dataDir = PathEx.Combine(PathEx.LocalDir, "Data"); var fileMap = new Dictionary <string, string> { { PathEx.Combine(appDir, "UserSettings.ini"), PathEx.Combine(dataDir, "UserSettings.ini") } }; Helper.ApplicationStart(updaterPath, "/silent", null); if (!File.Exists(appPath)) { var updIniPath = Path.ChangeExtension(updaterPath, ".ini"); if (!string.IsNullOrEmpty(updIniPath) && File.Exists(updIniPath)) { File.Delete(updIniPath); } return; } Helper.FileForwarding(Helper.Options.Start, fileMap, true); Helper.ApplicationStart(appPath, EnvironmentEx.CommandLine(false), false); Helper.FileForwarding(Helper.Options.Exit, fileMap, true); } }
private static void Main() { Log.AllowLogging(); using (new Mutex(true, Process.GetCurrentProcess().ProcessName, out bool newInstance)) { if (!newInstance) { return; } #if x86 var curPath64 = PathEx.Combine(PathEx.LocalDir, "TS3Client64Portable.exe"); if (Environment.Is64BitOperatingSystem && File.Exists(curPath64)) { ProcessEx.Start(curPath64, EnvironmentEx.CommandLine()); return; } var appDir = PathEx.Combine(PathEx.LocalDir, "App\\ts3_x86"); var appPath = PathEx.Combine(appDir, "ts3client_win32.exe"); const string appName = "ts3client_win32"; #else var appDir = PathEx.Combine(PathEx.LocalDir, "App\\ts3_x64"); var appPath = PathEx.Combine(appDir, "ts3client_win64.exe"); const string appName = "ts3client_win64"; #endif var updPath = PathEx.Combine(appDir, "update.exe"); if (!File.Exists(updPath) || ProcessEx.IsRunning(appName)) { return; } var iniPath = Path.ChangeExtension(PathEx.LocalPath, ".ini"); if (string.IsNullOrEmpty(iniPath)) { return; } if (!File.Exists(iniPath)) { var iniContent = new[] { "[Settings]", "", "; True to hide TeamSpeak on the Windows taskbar; otherwise, False.", "HideInTaskBar=False", "", "; Time (in milliseconds) to wait for a network connection before TeamSpeak is started.", "; This option can be useful for the Windows autorun feature. If TeamSpeak is started", "; before the network connection is available, the connection is failed and no replay", "; occurs.", "WaitForNetwork=0", "", "; Sets the window state of TeamSpeak. Options: Maximized, Minimized or Normal.", "WinState=Normal" }; File.WriteAllLines(iniPath, iniContent); } var time = Ini.Read("Settings", "WaitForNetwork", 0, iniPath); if (time > 300000) { time = 300000; } if (time.IsBetween(1, 300000)) { for (var i = 0; i < time; i++) { if (NetEx.InternetIsAvailable()) { break; } Thread.Sleep(1); } } var dirMap = new Dictionary <string, string> { { PathEx.Combine(appDir, "config"), "%CurDir%\\Data" }, { "%LocalAppData%\\TeamSpeak 3", "%CurDir%\\Data\\Temp" }, { "%UserProfile%\\.TeamSpeak 3", "%CurDir%\\Data\\Temp\\.TeamSpeak 3" } }; Helper.DirectoryForwarding(Helper.Options.Start, dirMap); var regKeys = new[] { "HKCU\\Software\\TeamSpeak 3 Client", "HKCR\\.ts3_addon", "HKCR\\.ts3_iconpack", "HKCR\\.ts3_plugin", "HKCR\\.ts3_soundpack", "HKCR\\.ts3_style", "HKCR\\.ts3_translation", "HKCR\\ts3addon" }; var firstKey = regKeys.LastOrDefault(); Helper.RegForwarding(Helper.Options.Start, firstKey); Reg.Write(firstKey, null, appDir); Reg.Write(firstKey, "ConfigLocation", 1, RegistryValueKind.String); Process appProcess = null; if (File.Exists(appPath)) { appProcess = ProcessEx.Start(appPath, EnvironmentEx.CommandLine(false), Elevation.IsAdministrator, false); } else { ProcessEx.Start(updPath, Elevation.IsAdministrator, false)?.WaitForExit(); } var wrapper = PathEx.Combine(appDir, "createfileassoc.exe"); var hide = Ini.Read("Settings", "HideInTaskBar", false, iniPath); var state = Ini.Read("Settings", "WinState", iniPath); var enable = state.EqualsEx("Maximized", "Minimized", iniPath); if (appProcess == null) { goto Second; } First: while (!appProcess.HasExited) { appProcess.WaitForExit(1000); if (File.Exists(wrapper) && !Crypto.EncryptFileToMd5(wrapper).EqualsEx("cdbe3628ca898a852502c8ae897e5a54")) { try { File.WriteAllBytes(wrapper, Resources.EmptyWrapper); } catch (Exception ex) { Log.Write(ex); } } if (!hide && !enable) { continue; } var hWnd = WinApi.NativeHelper.FindWindowByCaption("TeamSpeak 3"); if (hWnd == IntPtr.Zero) { continue; } if (hide) { hide = false; TaskBar.DeleteTab(hWnd); } if (!enable) { continue; } enable = false; WinApi.NativeHelper.ShowWindowAsync(hWnd, state.EqualsEx("Minimized") ? WinApi.ShowWindowFlags.ShowMinimized : WinApi.ShowWindowFlags.ShowMaximized); } while (ProcessEx.IsRunning(appName)) { Thread.Sleep(200); } Second: for (var i = 0; i < 10; i++) { while (ProcessEx.IsRunning(updPath) || WinApi.NativeHelper.FindWindowByCaption("TeamSpeak 3 Client Update") != IntPtr.Zero) { Thread.Sleep(200); } if (ProcessEx.IsRunning(appName)) { appProcess = Process.GetProcessesByName(appName).FirstOrDefault(); if (appProcess == null) { break; } hide = Ini.Read("Settings", "HideInTaskBar", false, iniPath); enable = state.EqualsEx("Maximized", "Minimized", iniPath); goto First; } Thread.Sleep(250); } Helper.DirectoryForwarding(Helper.Options.Exit, dirMap); Helper.RegForwarding(Helper.Options.Exit, firstKey); var rootKeys = regKeys.Skip(1).ToArray(); if (rootKeys.Any(Reg.SubKeyExists)) { var regSecureMap = rootKeys.ToDictionary <string, string, Dictionary <string, string> >(x => $"-{x}", x => null); Helper.RegSecureOverwrite(regSecureMap, true); } try { var qtWebEngineCacheDir = PathEx.Combine("%UserProfile%\\.QtWebEngineProcess"); if (Directory.Exists(qtWebEngineCacheDir)) { Directory.Delete(qtWebEngineCacheDir, true); } var owInstallerPath = Path.Combine(appDir, "OverwolfTeamSpeakInstaller.exe"); if (File.Exists(owInstallerPath)) { File.Delete(owInstallerPath); } } catch (Exception ex) { Log.Write(ex); } } }
private static void Main() { Log.AllowLogging(); try { using (new Mutex(true, ProcessEx.CurrentName, out bool newInstance)) { if (!newInstance) { return; } var appDir = PathEx.Combine(PathEx.LocalDir, "App\\ZedAttackProxy"); var appPaths = Directory.GetFiles(appDir, "zap-*.jar", SearchOption.TopDirectoryOnly).ToList(); appPaths.Sort(); var appPath = appPaths.Last(); if (!File.Exists(appPath) || IsRunning()) { return; } var iniPath = Path.ChangeExtension(PathEx.LocalPath, ".ini"); Helper.FindJava(out string javaPath, iniPath); var dirMap = new Dictionary <string, string> { { "%UserProfile%\\OWASP ZAP", "%CurDir%\\Data" } }; Helper.DirectoryForwarding(Helper.Options.Start, dirMap); var args = $"-Xmx512m -XX:PermSize=256M -jar \"{appPath}\" {EnvironmentEx.CommandLine(false)}".Trim(); using (var p = ProcessEx.Start(javaPath, Path.GetDirectoryName(appPath), args, false, false)) if (p?.HasExited == false) { p.WaitForExit(); } Recheck: var appName = Path.GetFileNameWithoutExtension(javaPath); foreach (var p in ProcessEx.GetInstances(appName)) { var wasRunning = false; bool isRunning; do { isRunning = p?.GetCommandLine()?.ContainsEx(appDir) == true; if (p?.HasExited == false) { p.WaitForExit(); } if (!wasRunning && isRunning) { wasRunning = true; } Thread.Sleep(200); }while (isRunning); if (!wasRunning) { continue; } Thread.Sleep(250); goto Recheck; } Helper.DirectoryForwarding(Helper.Options.Exit, dirMap); } } catch (Exception ex) { Log.Write(ex); } }
private static void Main() { Log.AllowLogging(); using (new Mutex(true, ProcessEx.CurrentName, out bool newInstance)) { #if x86 if (Environment.Is64BitOperatingSystem) { var curName = Path.GetFileNameWithoutExtension(PathEx.LocalPath); var curPath64 = PathEx.Combine(PathEx.LocalDir, $"{curName}64.exe"); ProcessEx.Start(curPath64, EnvironmentEx.CommandLine(false)); return; } #endif var appDir = PathEx.Combine(PathEx.LocalDir, "App\\Steam"); var appPath = Path.Combine(appDir, "Steam.exe"); var cmdLine = EnvironmentEx.CommandLine(false); if (!newInstance) { ProcessEx.Start(appPath, cmdLine, true); return; } var iniPath = Path.ChangeExtension(PathEx.LocalPath, ".ini"); if (string.IsNullOrEmpty(iniPath)) { return; } const string steamAppsDefVar = "%CurDir%\\Data\\steamapps"; if (!File.Exists(iniPath)) { var iniContent = new[] { "[Settings]", "", "; True to clear caches when Steam is closed; otherwise, False.", "ImproveSteamStartTime=True", "", "; This option allows forwarding of the default steam game install directory.", "; Steam handles this directory as if would be still on the default location.", $"SteamAppsPathOverride={steamAppsDefVar}", "", "; Set start arguments that are used when Steam Portable creates a new instance.", "; Options: https://developer.valvesoftware.com/wiki/Command_Line_Options", ";StartArguments=-silent steam://friends/status/online" }; File.WriteAllLines(iniPath, iniContent); } var steamAppsVar = Ini.Read("Settings", "SteamAppsPathOverride", steamAppsDefVar, iniPath); if (!steamAppsVar.EqualsEx(steamAppsDefVar)) { var steamAppsDir = PathEx.Combine(steamAppsVar); if (!PathEx.IsValidPath(steamAppsDir)) { steamAppsVar = steamAppsDefVar; } } var defServiceDir = PathEx.Combine("%CommonProgramFiles(x86)%\\Steam"); var serviceDir = PathEx.Combine(PathEx.LocalDir, "App\\Service"); var dirMap = new Dictionary <string, string> { { defServiceDir, serviceDir }, { "%LocalAppData%\\Steam", "%CurDir%\\Data\\cache" }, { "%CurDir%\\App\\Steam\\steamapps", steamAppsVar } }; var dataDir = PathEx.Combine(PathEx.LocalDir, "Data"); foreach (var d in dirMap.Keys.Skip(2)) { var dir = PathEx.Combine(d); if (!Directory.Exists(dir) || Data.DirIsLink(dir)) { continue; } using (var p = ProcessEx.Send(string.Format(Resources.ForceMove, dir, dataDir), true, false)) if (p?.HasExited == false) { p.WaitForExit(); } if (!Directory.Exists(dir)) { continue; } try { Directory.Delete(dir, true); } catch (Exception ex) { Log.Write(ex); if (Data.ForceDelete(dir, true)) { continue; } if (Ini.ReadDirect("Cache", "Hard", iniPath).EqualsEx("True")) { Ini.WriteDirect("Cache", null, null, iniPath); continue; } Ini.WriteDirect("Cache", "Hard", true, iniPath); ProcessEx.Start(PathEx.LocalPath, EnvironmentEx.CommandLine(false), true); } } if (Ini.ReadDirect("Cache", "Hard", iniPath).EqualsEx("True")) { Ini.WriteDirect("Cache", null, null, iniPath); } Helper.DirectoryForwarding(Helper.Options.Start, dirMap); var scMap = new Dictionary <string, string> { { "%CurDir%\\App\\Steam\\appcache", "%CurDir%\\Data\\shortcuts\\appcache" }, { "%CurDir%\\App\\Steam\\config", "%CurDir%\\Data\\shortcuts\\config" }, { "%CurDir%\\App\\Steam\\depotcache", "%CurDir%\\Data\\shortcuts\\depotcache" }, { "%CurDir%\\App\\Steam\\dumps", "%CurDir%\\Data\\shortcuts\\dumps" }, { "%CurDir%\\App\\Steam\\htmlcache", "%CurDir%\\Data\\shortcuts\\htmlcache" }, { "%CurDir%\\App\\Steam\\logs", "%CurDir%\\Data\\shortcuts\\logs" }, { "%CurDir%\\App\\Steam\\music", "%CurDir%\\Data\\shortcuts\\music" }, { "%CurDir%\\App\\Steam\\remoteui", "%CurDir%\\Data\\shortcuts\\remoteui" }, { "%CurDir%\\App\\Steam\\skins", "%CurDir%\\Data\\shortcuts\\skins" }, { "%CurDir%\\App\\Steam\\userdata", "%CurDir%\\Data\\shortcuts\\userdata" }, { "%CurDir%\\App\\Steam\\vrpanorama", "%CurDir%\\Data\\shortcuts\\vrpanorama" } }; var scDir = Path.Combine(dataDir, "shortcuts"); foreach (var data in scMap) { var dir1 = PathEx.Combine(data.Key); var dir2 = PathEx.Combine(data.Value); try { if (Directory.Exists(dir2)) { Data.DirCopy(dir2, dir1, true, true); Directory.Delete(dir2, true); } if (!Directory.Exists(dir1)) { Directory.CreateDirectory(dir1); } if (!Directory.Exists(scDir)) { Directory.CreateDirectory(scDir); } } catch (Exception ex) { Log.Write(ex); } Data.CreateShortcut(dir1, dir2); } var regKeys = new[] { "HKCU\\Software\\Valve", "HKLM\\SOFTWARE\\Valve" #if !x86 , "HKLM\\SOFTWARE\\Wow6432Node\\Valve" #endif }; Helper.RegForwarding(Helper.Options.Start, regKeys); for (var i = 0; i < regKeys.Length; i++) { var regKey = $"{regKeys[i]}\\Steam"; switch (i) { case 0: Reg.Write(regKey, "SteamExe", PathEx.AltCombine(appPath).ToLower()); Reg.Write(regKey, "SteamPath", PathEx.AltCombine(appDir).ToLower()); Reg.Write(regKey, "SourceModInstallPath", PathEx.AltCombine(appDir, "steamapps\\sourcemods").ToLower()); regKey = $"{regKey}\\ActiveProcess"; Reg.Write(regKey, "SteamClientDll", PathEx.AltCombine(appDir, "steamclient.dll").ToLower()); Reg.Write(regKey, "SteamClientDll64", PathEx.AltCombine(appDir, "steamclient64.dll").ToLower()); break; case 1: #if !x86 case 2: #endif Reg.Write(regKey, "InstallPath", appDir); #if !x86 if (i == 1) { continue; } #endif regKey = $"{regKey}\\Apps\\CommonRedist"; Reg.Write($"{regKey}\\.NET\\3.5", "3.5 SP1", 1, RegistryValueKind.DWord); Reg.Write($"{regKey}\\.NET\\3.5 Client Profile", "3.5 Client Profile SP1", 1, RegistryValueKind.DWord); Reg.Write($"{regKey}\\.NET\\4.0", "4.0", 1, RegistryValueKind.DWord); Reg.Write($"{regKey}\\.NET\\4.0 Client Profile", "4.0 Client Profile", 1, RegistryValueKind.DWord); Reg.Write($"{regKey}\\.NET\\4.5", "4.5", 1, RegistryValueKind.DWord); Reg.Write($"{regKey}\\.NET\\4.5.1", "4.5.1", 1, RegistryValueKind.DWord); Reg.Write($"{regKey}\\.NET\\4.5.2", "4.5.2", 1, RegistryValueKind.DWord); Reg.Write($"{regKey}\\.NET\\4.6", "4.6", 1, RegistryValueKind.DWord); Reg.Write($"{regKey}\\.NET\\4.6.1", "4.6.1", 1, RegistryValueKind.DWord); var value = File.Exists(PathEx.Combine("%system%\\d3d9.dll")) ? 1 : 0; Reg.Write($"{regKey}\\DirectX", "June2010", value, RegistryValueKind.DWord); Reg.Write($"{regKey}\\DirectX\\Jun2010", "dxsetup", value, RegistryValueKind.DWord); value = EnvironmentEx.Redist.IsInstalled(EnvironmentEx.Redist.Flags.VC2005X86) ? 1 : 0; Reg.Write($"{regKey}\\vcredist\\2005", "x86 SP1", value, RegistryValueKind.DWord); value = EnvironmentEx.Redist.IsInstalled(EnvironmentEx.Redist.Flags.VC2005X64) ? 1 : 0; Reg.Write($"{regKey}\\vcredist\\2005", "x64 SP1", value, RegistryValueKind.DWord); value = EnvironmentEx.Redist.IsInstalled(EnvironmentEx.Redist.Flags.VC2008X86) ? 1 : 0; Reg.Write($"{regKey}\\vcredist\\2008", "x86 SP1", value, RegistryValueKind.DWord); value = EnvironmentEx.Redist.IsInstalled(EnvironmentEx.Redist.Flags.VC2008X64) ? 1 : 0; Reg.Write($"{regKey}\\vcredist\\2008", "x64 SP1", value, RegistryValueKind.DWord); value = EnvironmentEx.Redist.IsInstalled(EnvironmentEx.Redist.Flags.VC2010X86) ? 1 : 0; Reg.Write($"{regKey}\\vcredist\\2010", "x86", value, RegistryValueKind.DWord); value = EnvironmentEx.Redist.IsInstalled(EnvironmentEx.Redist.Flags.VC2010X64) ? 1 : 0; Reg.Write($"{regKey}\\vcredist\\2010", "x64", value, RegistryValueKind.DWord); value = EnvironmentEx.Redist.IsInstalled(EnvironmentEx.Redist.Flags.VC2012X86) ? 1 : 0; Reg.Write($"{regKey}\\vcredist\\2012", "x86 Update 2", value, RegistryValueKind.DWord); value = EnvironmentEx.Redist.IsInstalled(EnvironmentEx.Redist.Flags.VC2012X64) ? 1 : 0; Reg.Write($"{regKey}\\vcredist\\2012", "x64 Update 2", value, RegistryValueKind.DWord); value = EnvironmentEx.Redist.IsInstalled(EnvironmentEx.Redist.Flags.VC2013X86) ? 1 : 0; Reg.Write($"{regKey}\\vcredist\\2013", "x86 Update 1", value, RegistryValueKind.DWord); value = EnvironmentEx.Redist.IsInstalled(EnvironmentEx.Redist.Flags.VC2013X64) ? 1 : 0; Reg.Write($"{regKey}\\vcredist\\2013", "x64 Update 1", value, RegistryValueKind.DWord); value = EnvironmentEx.Redist.IsInstalled(EnvironmentEx.Redist.Flags.VC2015X86) ? 1 : 0; Reg.Write($"{regKey}\\vcredist\\2015", "x86", value, RegistryValueKind.DWord); value = EnvironmentEx.Redist.IsInstalled(EnvironmentEx.Redist.Flags.VC2015X64) ? 1 : 0; Reg.Write($"{regKey}\\vcredist\\2015", "x64", value, RegistryValueKind.DWord); value = EnvironmentEx.Redist.IsInstalled(EnvironmentEx.Redist.Flags.VC2017X86) ? 1 : 0; Reg.Write($"{regKey}\\vcredist\\2017", "x86", value, RegistryValueKind.DWord); value = EnvironmentEx.Redist.IsInstalled(EnvironmentEx.Redist.Flags.VC2017X64) ? 1 : 0; Reg.Write($"{regKey}\\vcredist\\2017", "x64", value, RegistryValueKind.DWord); break; } } const string serviceName = "Steam Client Service"; if (!Service.Exists(serviceName)) { try { var binSrvPath = Path.Combine(appDir, "bin\\steamservice.exe"); var srvPath = Path.Combine(serviceDir, "SteamService.exe"); File.Copy(binSrvPath, srvPath, true); binSrvPath = Path.ChangeExtension(binSrvPath, ".dll"); srvPath = Path.ChangeExtension(srvPath, ".dll"); File.Copy(binSrvPath, srvPath, true); } catch (Exception ex) { Log.Write(ex); } var defSrvPath = Path.Combine(defServiceDir, "SteamService.exe"); Service.Install(serviceName, serviceName, defSrvPath, "/RunAsService"); Service.Start(serviceName); } var startArgs = Ini.Read("Settings", "StartArguments", iniPath); if (!string.IsNullOrWhiteSpace(startArgs)) { cmdLine = $"{startArgs} {cmdLine}".Trim(); } Helper.ApplicationStart(appPath, cmdLine); if (Service.Exists(serviceName)) { Service.Stop(serviceName); Service.Uninstall(serviceName); } Helper.DirectoryForwarding(Helper.Options.Exit, dirMap); Helper.RegForwarding(Helper.Options.Exit, regKeys); var regSecureMap = new Dictionary <string, Dictionary <string, string> > { { "-HKCR\\steam", null } }; Helper.RegSecureOverwrite(regSecureMap); if (!Ini.Read("Settings", "ImproveSteamStartTime", false, iniPath)) { return; } if (Directory.Exists(scDir)) { try { Directory.Delete(scDir, true); } catch (Exception ex) { Log.Write(ex); } } var patternDict = new Dictionary <string, SearchOption> { { ".crash", SearchOption.TopDirectoryOnly }, { "*.old", SearchOption.TopDirectoryOnly }, { "*.log", SearchOption.AllDirectories }, { "*.log.last", SearchOption.TopDirectoryOnly }, { "ClientRegistry.blob", SearchOption.TopDirectoryOnly } }; foreach (var p in patternDict) { try { foreach (var f in Directory.EnumerateFiles(appDir, p.Key, p.Value)) { try { File.Delete(f); } catch (Exception ex) { Log.Write(ex); } } } catch (Exception ex) { Log.Write(ex); } } var dirs = new[] { Path.Combine(appDir, "appcache"), Path.Combine(appDir, "depotcache"), Path.Combine(appDir, "dumps"), Path.Combine(appDir, "htmlcache"), Path.Combine(dataDir, "cache") }; foreach (var d in dirs) { try { if (Directory.Exists(d)) { Directory.Delete(d, true); } } catch (Exception ex) { Log.Write(ex); } } } }
private static void Main() { Log.AllowLogging(); using (new Mutex(true, ProcessEx.CurrentName, out bool newInstance)) { var appDir = PathEx.Combine(PathEx.LocalDir, "App\\winamp"); var appPath = PathEx.Combine(appDir, "winamp.exe"); if (!File.Exists(appPath)) { return; } var iniPath = Path.ChangeExtension(PathEx.LocalPath, ".ini"); var sortArgs = Ini.ReadDirect("Settings", "SortArgs", iniPath).EqualsEx("True"); if (!newInstance) { ProcessEx.Start(appPath, EnvironmentEx.CommandLine(sortArgs)); return; } if (!File.Exists(iniPath)) { Ini.WriteDirect("Associations", "FileTypes", "mp3,mp2,mp1,aac,vlb,avi,cda,mkv,webm,nsv,nsa,swf,ogg,oga,m4a,mp4,mpg,mpeg,m2v,flac,flv,wma,wmv,asf,aiff,aif,au,avr,caf,htk,iff,mat,paf,pvf,raw,rf64,sd2,sds,sf,voc,w64,wav,wve,xi,mid,midi,rmi,kar,miz,mod,mdz,nst,stm,stz,s3m,s3z,it,itz,xm,xmz,mtm,ult,669,far,amf,okt,ptm,m3u,m3u8,pls,b4s,xspf,wpl,asx", iniPath); Ini.WriteDirect("Settings", "SortArgs", false, iniPath); } iniPath = PathEx.Combine(PathEx.LocalDir, "Data\\winamp.ini"); if (!File.Exists(iniPath)) { var langDir = Path.Combine(appDir, "Lang"); if (Directory.Exists(langDir)) { var langs = Directory.EnumerateFiles(langDir, "*.wlz").Select(Path.GetFileNameWithoutExtension).ToArray(); if (langs.Length > 0) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Form langSelection = new LangSelectionForm(langs, iniPath); if (langSelection.ShowDialog() != DialogResult.OK) { Application.Exit(); return; } } } } Ini.WriteDirect("Winamp", "no_registry", 0, iniPath); Ini.WriteDirect("WinampReg", "NeedReg", 0, iniPath); Ini.WriteDirect("Winamp", "skin", "Big Bento", iniPath, false, true); Ini.WriteDirect("WinampReg", "skin", "Big Bento", iniPath, false, true); Ini.WriteDirect("Winamp", "eq_data", "24,19,40,46,42,31,19,16,26,32", iniPath, false, true); Ini.WriteDirect("gen_hotkeys", "nbkeys", 15, iniPath, false, true); Ini.WriteDirect("gen_hotkeys", "version", 2, iniPath, false, true); Ini.WriteDirect("gen_hotkeys", "enabled", 0, iniPath, false, true); Ini.WriteDirect("gen_hotkeys", "appcommand", 0, iniPath, false, true); Ini.WriteDirect("gen_hotkeys", "action0", "ghkdc play", iniPath, false, true); Ini.WriteDirect("gen_hotkeys", "hotkey0", 3629, iniPath, false, true); Ini.WriteDirect("gen_hotkeys", "action1", "ghkdc pause", iniPath, false, true); Ini.WriteDirect("gen_hotkeys", "hotkey1", 3620, iniPath, false, true); Ini.WriteDirect("gen_hotkeys", "action2", "ghkdc stop", iniPath, false, true); Ini.WriteDirect("gen_hotkeys", "hotkey2", 3619, iniPath, false, true); Ini.WriteDirect("gen_hotkeys", "action3", "ghkdc prev", iniPath, false, true); Ini.WriteDirect("gen_hotkeys", "hotkey3", 3617, iniPath, false, true); Ini.WriteDirect("gen_hotkeys", "action4", "ghkdc next", iniPath, false, true); Ini.WriteDirect("gen_hotkeys", "hotkey4", 3618, iniPath, false, true); Ini.WriteDirect("gen_hotkeys", "action5", "ghkdc vup", iniPath, false, true); Ini.WriteDirect("gen_hotkeys", "hotkey5", 3622, iniPath, false, true); Ini.WriteDirect("gen_hotkeys", "action6", "ghkdc vdown", iniPath, false, true); Ini.WriteDirect("gen_hotkeys", "hotkey6", 3624, iniPath, false, true); Ini.WriteDirect("gen_hotkeys", "action7", "ghkdc forward", iniPath, false, true); Ini.WriteDirect("gen_hotkeys", "hotkey7", 3623, iniPath, false, true); Ini.WriteDirect("gen_hotkeys", "action8", "ghkdc rewind", iniPath, false, true); Ini.WriteDirect("gen_hotkeys", "hotkey8", 3621, iniPath, false, true); Ini.WriteDirect("gen_hotkeys", "action9", "ghkdc jump", iniPath, false, true); Ini.WriteDirect("gen_hotkeys", "hotkey9", 3658, iniPath, false, true); Ini.WriteDirect("gen_hotkeys", "action10", "ghkdc file", iniPath, false, true); Ini.WriteDirect("gen_hotkeys", "hotkey10", 3660, iniPath, false, true); Ini.WriteDirect("gen_hotkeys", "action11", "ghkdc stop", iniPath, false, true); Ini.WriteDirect("gen_hotkeys", "hotkey11", 2226, iniPath, false, true); Ini.WriteDirect("gen_hotkeys", "action12", "ghkdc play/pause", iniPath, false, true); Ini.WriteDirect("gen_hotkeys", "hotkey12", 2227, iniPath, false, true); Ini.WriteDirect("gen_hotkeys", "action13", "ghkdc prev", iniPath, false, true); Ini.WriteDirect("gen_hotkeys", "hotkey13", 2225, iniPath, false, true); Ini.WriteDirect("gen_hotkeys", "action14", "ghkdc next", iniPath, false, true); Ini.WriteDirect("gen_hotkeys", "hotkey14", 2224, iniPath, false, true); Ini.WriteDirect("gen_hotkeys", "col1", 212, iniPath, false, true); Ini.WriteDirect("gen_hotkeys", "col2", 177, iniPath, false, true); var dirMap = new Dictionary <string, string> { { "%CurDir%\\App\\winamp\\Plugins\\ml", "%CurDir%\\Data\\Plugins\\ml" } }; var fileMap = new Dictionary <string, string> { { "%CurDir%\\App\\winamp\\gen_jumpex.m3u8", "%CurDir%\\Data\\gen_jumpex.m3u8" }, { "%CurDir%\\App\\winamp\\winamp.bm", "%CurDir%\\Data\\winamp.bm" }, { "%CurDir%\\App\\winamp\\winamp.bm3", "%CurDir%\\Data\\winamp.bm3" }, { "%CurDir%\\App\\winamp\\winamp.bm8", "%CurDir%\\Data\\winamp.bm8" }, { "%CurDir%\\App\\winamp\\winamp.ini", "%CurDir%\\Data\\winamp.ini" }, { "%CurDir%\\App\\winamp\\winamp.m3u", "%CurDir%\\Data\\winamp.m3u" }, { "%CurDir%\\App\\winamp\\winamp.m3u8", "%CurDir%\\Data\\winamp.m3u8" }, { "%CurDir%\\App\\winamp\\winamp.q1", "%CurDir%\\Data\\winamp.q1" }, { "%CurDir%\\App\\winamp\\links.xml", "%CurDir%\\Data\\links.xml" }, { "%CurDir%\\App\\winamp\\studio.xnf", "%CurDir%\\Data\\studio.xnf" }, { "%CurDir%\\App\\winamp\\Plugins\\feedback.ini", "%CurDir%\\Data\\Plugins\\feedback.ini" }, { "%CurDir%\\App\\winamp\\Plugins\\gen_ml.ini", "%CurDir%\\Data\\Plugins\\gen_ml.ini" }, { "%CurDir%\\App\\winamp\\Plugins\\Milkdrop2\\milk2.ini", "%CurDir%\\Data\\Plugins\\Milkdrop2\\milk2.ini" }, { "%CurDir%\\App\\winamp\\Plugins\\Milkdrop2\\milk2_img.ini", "%CurDir%\\Data\\Plugins\\Milkdrop2\\milk2_img.ini" }, { "%CurDir%\\App\\winamp\\Plugins\\Milkdrop2\\milk2_msg.ini", "%CurDir%\\Data\\Plugins\\Milkdrop2\\milk2_msg.ini" } }; Helper.DirectoryForwarding(Helper.Options.Start, dirMap); Helper.FileForwarding(Helper.Options.Start, fileMap, true); Helper.ApplicationStart(appPath, EnvironmentEx.CommandLine(sortArgs)); Helper.DirectoryForwarding(Helper.Options.Exit, dirMap); Helper.FileForwarding(Helper.Options.Exit, fileMap, true); } }
private static void Main() { Log.AllowLogging(); #if x86 var curPath64 = PathEx.Combine(PathEx.LocalDir, "NTLite64Portable.exe"); if (Environment.Is64BitOperatingSystem && File.Exists(curPath64)) { ProcessEx.Start(curPath64, EnvironmentEx.CommandLine(false)); return; } var appDir = PathEx.Combine(PathEx.LocalDir, "App\\NTLite"); var updaterPath = PathEx.Combine(appDir, "NTLiteUpdater.exe"); #else var appDir = PathEx.Combine(PathEx.LocalDir, "App\\NTLite64"); var updaterPath = PathEx.Combine(appDir, "NTLiteUpdater64.exe"); #endif var appPath = Path.Combine(appDir, "NTLite.exe"); if (!File.Exists(updaterPath) || ProcessEx.IsRunning(Path.GetFileNameWithoutExtension(appPath)) || ProcessEx.IsRunning(Path.GetFileNameWithoutExtension(updaterPath))) { return; } using (new Mutex(true, ProcessEx.CurrentName, out bool newInstance)) { if (!newInstance) { return; } var dataDir = PathEx.Combine(PathEx.LocalDir, "Data"); try { var temp = Path.Combine(dataDir, "TEMP"); if (!Directory.Exists(temp)) { Directory.CreateDirectory(temp); } var cfgPath = Path.Combine(dataDir, "settings.xml"); if (File.Exists(cfgPath)) { var match = Regex.Match(File.ReadAllText(cfgPath), "<TempFolder>(.+?)</TempFolder>", RegexOptions.IgnoreCase).Groups[1].Value; if (!string.IsNullOrWhiteSpace(match)) { Encoding encoding; var sb = new StringBuilder(); using (var sr = new StreamReader(cfgPath)) { string line; encoding = sr.CurrentEncoding; while ((line = sr.ReadLine()) != null) { var m = Regex.Match(line, "<TempFolder>(.+?)</TempFolder>", RegexOptions.IgnoreCase).Groups[1].Value; if (!string.IsNullOrWhiteSpace(m)) { var dirName = Path.GetFileName(EnvironmentEx.GetVariableValue("CurDir")); if (dirName != null) { line = line.Replace(m, line.ToLower().Contains($"{dirName.ToLower()}\\data\\temp") ? temp : "%TEMP%"); } } sb.AppendLine(line); } } using (var sw = new StreamWriter(cfgPath, false, encoding)) sw.Write(sb.ToString()); } } else { var content = Resources.DefaultSetting; content = content.Replace("%TEMP%", temp); using (var sw = File.CreateText(cfgPath)) sw.Write(content); } } catch (Exception ex) { Log.Write(ex); } try { var srcDir = PathEx.Combine(appDir, "Presets"); if (Directory.Exists(srcDir) && !Data.DirIsLink(srcDir)) { var destDir = PathEx.Combine(dataDir, "Presets"); Data.DirCopy(srcDir, destDir, true, true); Directory.Delete(srcDir, true); } } catch (Exception ex) { Log.Write(ex); } var dirMap = new Dictionary <string, string> { { PathEx.Combine(appDir, "Presets"), PathEx.Combine(dataDir, "Presets") } }; var fileMap = new Dictionary <string, string> { { Path.Combine(appDir, "settings.xml"), Path.Combine(dataDir, "settings.xml") }, { Path.Combine(appDir, "settingsUI.xml"), Path.Combine(dataDir, "settingsUI.xml") } }; Helper.ApplicationStart(updaterPath, "/silent", null); if (!File.Exists(appPath)) { var updIniPath = Path.ChangeExtension(updaterPath, ".ini"); if (!string.IsNullOrEmpty(updIniPath) && File.Exists(updIniPath)) { File.Delete(updIniPath); } return; } Helper.DirectoryForwarding(Helper.Options.Start, dirMap); Helper.FileForwarding(Helper.Options.Start, fileMap, true); Helper.ApplicationStart(appPath, EnvironmentEx.CommandLine(false), false); Helper.DirectoryForwarding(Helper.Options.Exit, dirMap); Helper.FileForwarding(Helper.Options.Exit, fileMap, true); } }
private static void Main() { Log.FileDir = Path.Combine(TmpDir, "logs"); Ini.SetFile(PathEx.LocalDir, "Settings.ini"); Ini.SortBySections = new[] { "History", "Host", "Settings" }; Log.AllowLogging(Ini.FilePath); #if x86 string appsLauncher64; if (Environment.Is64BitOperatingSystem && File.Exists(appsLauncher64 = PathEx.Combine(PathEx.LocalDir, $"{ProcessEx.CurrentName}64.exe"))) { ProcessEx.Start(appsLauncher64, EnvironmentEx.CommandLine(false)); return; } #endif if (!RequirementsAvailable()) { var updPath = PathEx.Combine(PathEx.LocalDir, "Binaries\\Updater.exe"); if (File.Exists(updPath)) { ProcessEx.Start(updPath); } else { Lang.ResourcesNamespace = typeof(Program).Namespace; if (MessageBox.Show(Lang.GetText(nameof(en_US.RequirementsErrorMsg)), Resources.Titel, MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.Yes) { Process.Start(PathEx.AltCombine(Resources.GitProfileUri, Resources.GitReleasesPath)); } } return; } if (Log.DebugMode < 2) { CheckEnvironmentVariable(); } var instanceKey = PathEx.LocalPath.GetHashCode().ToString(); using (new Mutex(true, instanceKey, out bool newInstance)) { MessageBoxEx.TopMost = true; Lang.ResourcesNamespace = typeof(Program).Namespace; if (newInstance && ReceivedPathsArray.Count == 0 || ActionGuid.IsAllowNewInstance) { SetInterfaceSettings(); Application.Run(new MenuViewForm().Plus()); return; } if (EnvironmentEx.CommandLineArgs(false).Count == 0) { return; } if ((newInstance || ActionGuid.IsAllowNewInstance) && !ActionGuid.IsDisallowInterface) { SetInterfaceSettings(); Application.Run(new OpenWithForm().Plus()); return; } if (ActionGuid.IsRepairDirs) { return; } if (EnvironmentEx.CommandLineArgs(false).Count == 2) { var first = EnvironmentEx.CommandLineArgs(false).First(); switch (first) { case ActionGuid.FileTypeAssociation: SetInterfaceSettings(); AssociateFileTypesHandler(EnvironmentEx.CommandLineArgs(false).Skip(1).First()); return; case ActionGuid.RestoreFileTypes: SetInterfaceSettings(); RestoreFileTypesHandler(EnvironmentEx.CommandLineArgs(false).Skip(1).First()); return; case ActionGuid.SystemIntegration: SetInterfaceSettings(); SystemIntegrationHandler(EnvironmentEx.CommandLineArgs(false).Skip(1).First().ToBoolean()); return; } } if (ReceivedPathsArray.Count == 0) { return; } IntPtr hWnd; do { hWnd = Reg.Read(RegPath, "Handle", IntPtr.Zero); }while (hWnd == IntPtr.Zero); WinApi.NativeHelper.SendArgs(hWnd, ReceivedPathsStr); } }