static Info() { System.IO.Directory.CreateDirectory(Directory); try { if (Autostart && GetAutostartPath(Name) != ExecutablePath) { SetAutostartPath(Name, ExecutablePath); } }catch (Exception e) { CLIOutput.WriteLine("Failed to set autostart path: probably program doesn't have permissions to do that!", ConsoleColor.DarkYellow); #if DEBUG CLIOutput.WriteLine(e.StackTrace); #endif } }
private static void SetAutostartPath(string name, string path) { try { using (RegistryKey rk = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true)) { if (path != null) { rk.SetValue(name, path, RegistryValueKind.String); } else { rk.DeleteValue(name); } } }catch (Exception) { CLIOutput.WriteLine("Failed to set autostart path: probably program doesn't have permissions to do that!", ConsoleColor.DarkYellow); } }
public void Log(string str, params object[] parameters) { CLIOutput.WriteLine("| " + str, ConsoleColor.Gray, parameters); }