internal static bool IsRunning() { string mfg = Branding.GetString("BRANDING_manufacturer"); if (String.IsNullOrEmpty(mfg)) { mfg = "Citrix"; } string app = Branding.GetString("BRANDING_updater"); if (String.IsNullOrEmpty(app)) { app = "ManagementAgentUpdater"; } mfg = mfg.Replace(' ', '_'); app = app.Replace(' ', '_'); string name = @"Global\" + mfg + "_" + app + "_SingleInstanceMutex"; bool created; __mutex = new Mutex(true, name, out created); if (created) { return(false); } Program.Log("Another instance is running"); return(true); }
public string GetString(string key) { return(Branding.GetString(key)); }
private Update CheckForUpdates() { string url = Branding.GetString("BRANDING_updaterURL"); if (String.IsNullOrEmpty(url)) { url = "https://pvupdates.vmd.citrix.com/updates.tsv"; } if (update_url.Exists) { url = update_url.Value; } url = (string)GetReg("HKEY_LOCAL_MACHINE\\SOFTWARE\\Citrix\\XenTools", "update_url", url); if (String.IsNullOrEmpty(url)) { session.Log("Update URL is Null or Empty"); throw new ArgumentNullException("URL is empty"); } session.Log("Checking URL: " + url + " for updates after: " + version.ToString()); WebClient client = new WebClient(); string contents = client.DownloadString(url); string arch = (Win32Impl.Is64BitOS() && (!Win32Impl.IsWOW64())) ? "x64" : "x86"; List <Update> updates = new List <Update>(); foreach (string line in contents.Split(new char[] { '\n' })) { if (String.IsNullOrEmpty(line)) { continue; } try { Update update = new Update(line); if (update.Arch != arch) { continue; } if (update.Version.CompareTo(version) <= 0) { continue; } updates.Add(update); session.Log("Update Entry :" + update.ToString()); } catch (Exception e) { session.Log("Exception: " + e.Message); } } updates.Reverse(); if (updates.Count > 0) { return(updates[0]); } session.Log("No updates found"); return(null); }