Example #1
0
        public static void DeleteDrivers()
        {
            var silverleafDrivers = GetVMSpcDrivers();

            if (silverleafDrivers != null && silverleafDrivers.Count < 3)
            {
                var message = "VMSpc will uninstall the drivers by their oem files: ";
                foreach (var driver in silverleafDrivers)
                {
                    message += $"{driver.PublishedName}, ";
                }
                message += "are you sure you want to proceed?";
                if (MessageBox.Show(message, "Delete Drivers", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    foreach (var driver in silverleafDrivers)
                    {
                        var result = BatchExecutor.ExecuteCommand($"pnputil -f -d {driver.PublishedName}", true);
                        MessageBox.Show(result.StandardOutput);
                        MessageBox.Show(result.StandardError);
                    }
                }
            }
        }
Example #2
0
        public static List <DriverDetail> GetDrivers()
        {
            bool bWow64 = false;

            IsWow64Process(Process.GetCurrentProcess().Handle, out bWow64);
            if (bWow64)
            {
                IntPtr OldValue = IntPtr.Zero;
                bool   bRet     = Wow64DisableWow64FsRedirection(out OldValue);
            }
            var output      = BatchExecutor.ExecuteCommand("pnputil -e");
            var entries     = new List <DriverDetail>();
            var splitOutput = output.StandardOutput.Split(new string[] { "\n\n" }, StringSplitOptions.RemoveEmptyEntries);

            foreach (var outputSegment in splitOutput)
            {
                if (outputSegment.StartsWith("Published name"))
                {
                    var entry = new DriverDetail(outputSegment);
                    entries.Add(entry);
                }
            }
            return(entries);
        }