/// <summary> /// Update registry with new UpdateUrl path, Office version required as paths are different /// </summary> /// <param name="OfficeVersion"></param> /// <param name="UpdatePath"></param> /// <returns></returns> static bool SetUpdateUrl(int OfficeVersion, string UpdatePath) { string regPath = string.Empty; if (OfficeVersion == 16) { regPath = keyPath16; } else { regPath = keyPath15; } try { RegistryHelpers.SetRegistryValue(regPath, UpdatePathKey, UpdatePath); LogMessage("Registry update success at " + regPath + "\\" + UpdatePathKey); return(true); } catch (Exception ex) { LogMessage("Failed to update " + regPath + "\\" + UpdatePathKey); LogMessage(string.Format("Exception occured:{0}, {1}", ex.Message, ex.StackTrace.ToString())); return(false); } }
/// <summary> /// Start officec2rclient.exe with supplied params /// </summary> /// <param name="OfficeVersion"></param> /// <returns></returns> static bool LaunchUpdateProcess(int OfficeVersion) { string _officeConfigPath = string.Empty; if (OfficeVersion == 16) { _officeConfigPath = keyPath16; } else { _officeConfigPath = keyPath15; } string exePath = RegistryHelpers.GetRegistryValue(_officeConfigPath, OfficeC2RClientPathKey) as string; if (File.Exists(Path.Combine(exePath, C2RClientExe))) { // Launch it Process p; try { p = new Process(); p.StartInfo.WorkingDirectory = exePath; p.StartInfo.FileName = C2RClientExe; p.StartInfo.Arguments = C2RClientArg + " " + _officec2rClientArgs; //do we need to cater for quotes LogMessage("Starting " + p.StartInfo.FileName + " with params " + p.StartInfo.Arguments); p.Start(); return(true); } catch (Exception ex) { LogMessage("Failed to launch C2RClientExe"); LogMessage(string.Format("Exception occured:{0}, {1}", ex.Message, ex.StackTrace.ToString())); return(false); } } else { LogMessage(string.Format("OfficeC2RClient.exe doesn't exist at {0}", exePath)); return(false); } }
/// <summary> /// Determine which Office version is installed on users PC /// </summary> /// <returns>15, or 16, or -1 if no Office / failure </returns> static int GetOfficeVersion() { try { //must be better way of doing this string c2rclientPath = RegistryHelpers.GetRegistryValue(keyPath16, OfficeC2RClientPathKey) as string; if (c2rclientPath != null) { if (File.Exists(Path.Combine(c2rclientPath, C2RClientExe))) { return(16); } } else { LogMessage("Couldnt open registy key for Office 16 " + keyPath16 + " value " + OfficeC2RClientPathKey); } c2rclientPath = RegistryHelpers.GetRegistryValue(keyPath15, OfficeC2RClientPathKey) as string; if (c2rclientPath != null) { if (File.Exists(Path.Combine(c2rclientPath, C2RClientExe))) { return(15); } } else { LogMessage("Couldnt open registy key for Office 15 " + keyPath15 + " value " + OfficeC2RClientPathKey); } return(-1); } catch (Exception ex) { LogMessage("Error trying to open registry keys to identify Office version installed"); LogMessage(string.Format("Exception occured:{0}, {1}", ex.Message, ex.StackTrace.ToString())); return(-1); } }
/// <summary> /// Get Office 365 Pro Plus updateurl from registry /// </summary> /// <param name="OfficeVersion">15 or 16 supported</param> /// <returns></returns> static string GetOfficeUpdateUrl(int OfficeVersion) { try { string regPath = string.Empty; if (OfficeVersion == 16) { regPath = keyPath16; } else { regPath = keyPath15; } string updateUrl = RegistryHelpers.GetRegistryValue(regPath, UpdatePathKey) as string; return(updateUrl.ToLower()); } catch (Exception ex) { LogMessage("Error getting UpdateURL from registry"); LogMessage(string.Format("Exception occured:{0}, {1}", ex.Message, ex.StackTrace.ToString())); return(string.Empty); } }