Example #1
0
        public void RUNPS()
        {
            Console.WriteLine("Check RunPS...");

            var oRes = SWUpdate._RunPS("sleep 5", "", new TimeSpan(0, 0, 40));

            oRes.ToString();
            Assert.IsNotNull(oRes);
        }
        private void miUninstall_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (lvSW.SelectedItems.Count > 0)
                {
                    try
                    {
                        string sProdName = ((AddSoftware)lvSW.SelectedItem).ProductName;

                        List <AddSoftware> possibleSW = lInstalledSW.Where(t => t.Manufacturer == ((AddSoftware)lvSW.SelectedItem).Manufacturer & t.ProductVersion == ((AddSoftware)lvSW.SelectedItem).MSIProductID).ToList();
                        if (possibleSW.Count == 1)
                        {
                            SWUpdate._RunPS(possibleSW[0].PSUninstall.ToString());
                        }

                        if (possibleSW.Count > 1)
                        {
                            bool bRun = false;
                            foreach (AddSoftware aSW in possibleSW)
                            {
                                string subProdName = new String(sProdName.Where(c => c != '-' && c != '.' && (c <'0' || c> '9')).ToArray()).Trim();
                                if (subProdName == new String(aSW.ProductName.Where(c => c != '-' && c != '.' && (c < '0' || c > '9')).ToArray()).Trim())
                                {
                                    SWUpdate._RunPS(aSW.PSUninstall.ToString());
                                    bRun = true;
                                    continue;
                                }
                            }

                            if (!bRun)
                            {
                                Process.Start("control", "appwiz.cpl");
                            }
                        }
                    }
                    catch { }
                }
            }
            catch { }
        }