/// <summary> /// Called when [uninstall software]. /// </summary> /// <param name="UninstallString">The uninstall string.</param> /// <returns>json object.if successful return a array of Software match UninstallString registry key we try to uninstall them else return error</returns> public OnGetSoftwareListResponse OnUninstallSoftware(string UninstallString) { OnGetSoftwareListResponse JOnUninstallSoftware = new OnGetSoftwareListResponse(); try { _m_File_Manager mfm = new _m_File_Manager(); OnGetSoftwareListResponse JAllSoftwareFind = OnSerachSoftware("UninstallString", UninstallString); JOnUninstallSoftware = JAllSoftwareFind; foreach (OnGetSoftwareListResponse.Software JTarget in JAllSoftwareFind.software) { string InstallLocation = ""; if (JTarget.InstallLocation != null) { InstallLocation = JTarget.InstallLocation; } else//extract InstallLocation from UninstallString { InstallLocation = GetPathFromFullPath(UninstallString); } KillOpenedProcessFromPath(InstallLocation); KillDesktopLNKFromPath(InstallLocation); mfm.OnDeleteDirectory(InstallLocation); Utils._s_Utils_Registry_Manager.DeleteKey(JTarget.RegistryKeyAddress); } } catch (Exception ex) { JOnUninstallSoftware.Errors.AddErrorToErrorList(MethodBase.GetCurrentMethod().ToString(), ex.Message); } return(JOnUninstallSoftware); }
/// <summary> /// Called when [serach software]. /// </summary> /// <param name="Filter_Key">The filter key.</param> /// <param name="Filter_Value">The filter value.</param> /// <returns>json object.if successful return a array of Software installed on system by filtered include important information from each one else return error</returns> public OnGetSoftwareListResponse OnSerachSoftware(string Filter_Key, string Filter_Value) { OnGetSoftwareListResponse OnSerachSoftware = new OnGetSoftwareListResponse(); try { Response.OnGetSoftwareListResponse JSoftwares = OnGetSoftwareList(); foreach (Response.OnGetSoftwareListResponse.Software JSoftware in JSoftwares.software) { Type Filter_Key_Field = typeof(Module_Software_Manager.Response.OnGetSoftwareListResponse.Software); FieldInfo Filter_Key_Field_Info = Filter_Key_Field.GetField(Filter_Key); if (Filter_Key_Field_Info != null) { Type Target_Key_Field = JSoftware.GetType(); FieldInfo Target_Key_Field_Info = Target_Key_Field.GetField(Filter_Key); object retvalue = Target_Key_Field_Info.GetValue(JSoftware); if (retvalue?.ToString() == Filter_Value) { OnSerachSoftware.software.Add(JSoftware); } } } } catch (Exception ex) { OnSerachSoftware.Errors.AddErrorToErrorList(MethodBase.GetCurrentMethod().ToString(), ex.Message); } return(OnSerachSoftware); }
private void OnGetSoftwareList(string ResponseToOnGetSoftwareList) { Module_Software_Manager._m_Software_Manager msm = new Module_Software_Manager._m_Software_Manager(); OnGetSoftwareListResponse SoftwareList = msm.OnGetSoftwareList(); mocm.HubsManager.GetHub("CommandHub").Invoke(ResponseToOnGetSoftwareList, SoftwareList); }
private void OnSerachSoftware(string Filter_Key, string Filter_Value, string ResponseToOnSerachSoftware) { Module_Software_Manager._m_Software_Manager msm = new Module_Software_Manager._m_Software_Manager(); OnGetSoftwareListResponse SoftwareList = msm.OnSerachSoftware(Filter_Key, Filter_Value); mocm.HubsManager.GetHub("CommandHub").Invoke(ResponseToOnSerachSoftware, SoftwareList); }
private void OnUninstallSoftware(string UninstallString, string ResponseToOnUninstallSoftware) { Module_Software_Manager._m_Software_Manager msm = new Module_Software_Manager._m_Software_Manager(); OnGetSoftwareListResponse UninstalledSoftwareList = msm.OnUninstallSoftware(UninstallString); mocm.HubsManager.GetHub("CommandHub").Invoke(ResponseToOnUninstallSoftware, UninstalledSoftwareList); }
/// <summary> /// Called when [get software list]. /// </summary> /// <returns>jarray object.if successful return a array of Software installed on system include important information from each one else return error</returns> public OnGetSoftwareListResponse OnGetSoftwareList() { OnGetSoftwareListResponse JOnGetSoftwareListResponse = new OnGetSoftwareListResponse(); try { foreach (KeyValuePair <RegistryKey, string> RegistryUninstallKey in RegistryUninstallKeys) { RegistryKey KeyObject = null; string[] Keys = Utils._s_Utils_Registry_Manager.ReadAllKey(ref KeyObject, RegistryUninstallKey.Key, RegistryUninstallKey.Value); if (Keys == null) { continue; } foreach (string SubkeyName in Keys) { RegistryKey SubKeyObject = null; string[] SubKeys = Utils._s_Utils_Registry_Manager.ReadAllKey(ref SubKeyObject, KeyObject, SubkeyName); if (SubKeyObject.GetValue("UninstallString") != null) { if (SubKeyObject.GetValue("SystemComponent") == null) { if (SubKeyObject.GetValue("ParentDisplayName") == null) { if (SubKeyObject.GetValue("DisplayName") != null) { OnGetSoftwareListResponse.Software JSoftware = new OnGetSoftwareListResponse.Software(); JSoftware.DisplayName = SubKeyObject.GetValue("DisplayName").ToString(); JSoftware.Publisher = SubKeyObject.GetValue("Publisher")?.ToString(); JSoftware.InstallDate = GetSoftwareInstallTime(SubKeyObject); JSoftware.InstallLocation = SubKeyObject.GetValue("InstallLocation")?.ToString(); JSoftware.Size = SubKeyObject.GetValue("Size")?.ToString(); JSoftware.DisplayVersion = SubKeyObject.GetValue("DisplayVersion")?.ToString(); JSoftware.EstimatedSize = SubKeyObject.GetValue("EstimatedSize")?.ToString(); JSoftware.UninstallString = SubKeyObject.GetValue("UninstallString")?.ToString(); JSoftware.RegistryKeyAddress = SubKeyObject.Name; JOnGetSoftwareListResponse.software.Add(JSoftware); } } } } } } } catch (Exception ex) { JOnGetSoftwareListResponse.Errors.AddErrorToErrorList(MethodBase.GetCurrentMethod().ToString(), ex.Message); } return(JOnGetSoftwareListResponse); }
/// <summary> /// Starts the watching. /// </summary> public void StartWatching() { _m_Software_Manager msm = new _m_Software_Manager(); while (keepRunning) { System.Threading.Thread.Sleep(1000); OnGetSoftwareListResponse SoftWareList = msm.OnGetSoftwareList(); foreach (OnGetSoftwareListResponse.Software SoftwareName in SoftWareList.software) { foreach (string BlackSoftwareDisplayName in BlackSoftwareList) { if (SoftwareName.DisplayName == BlackSoftwareDisplayName) { msm.OnUninstallSoftware(SoftwareName.UninstallString); } } } } }