Exemple #1
0
        private static void ScanInstallFolders()
        {
            var regKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\Folders");

            if (regKey == null)
            {
                return;
            }

            foreach (var folder in regKey.GetValueNames()
                     .Where(folder => !string.IsNullOrWhiteSpace(folder))
                     .Where(folder => !ScanFunctions.DirExists(folder) && !Wizard.IsOnIgnoreList(folder))
                     .TakeWhile(folder => !CancellationToken.IsCancellationRequested))
            {
                Wizard.StoreInvalidKey(Strings.InvalidFile, regKey.Name, folder);
            }
        }
Exemple #2
0
        /// <summary>
        ///     Verifies installed programs in add/remove list
        /// </summary>
        public override void Scan()
        {
            try
            {
                Wizard.Report.WriteLine("Verifying programs in Add/Remove list");

                using (
                    var regKey =
                        Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"))
                {
                    if (regKey == null)
                    {
                        return;
                    }

                    foreach (
                        var progName in
                        regKey.GetSubKeyNames().TakeWhile(progName => !CancellationToken.IsCancellationRequested)
                        )
                    {
                        using (var regKey2 = regKey.OpenSubKey(progName))
                        {
                            if (regKey2 == null)
                            {
                                continue;
                            }

                            var progInfo = new ProgramInfo(regKey2);

                            if (regKey2.ValueCount <= 0)
                            {
                                Wizard.StoreInvalidKey(Strings.InvalidRegKey, regKey2.ToString());
                                continue;
                            }

                            if (progInfo.WindowsInstaller)
                            {
                                continue;
                            }

                            if (string.IsNullOrEmpty(progInfo.DisplayName) && !progInfo.Uninstallable)
                            {
                                Wizard.StoreInvalidKey(Strings.InvalidRegKey, regKey2.ToString());
                                continue;
                            }

                            // Check display icon
                            if (!string.IsNullOrEmpty(progInfo.DisplayIcon))
                            {
                                if (!ScanFunctions.IconExists(progInfo.DisplayIcon))
                                {
                                    Wizard.StoreInvalidKey(Strings.InvalidFile, regKey2.ToString(), "DisplayIcon");
                                }
                            }

                            // Check install location
                            if (!string.IsNullOrEmpty(progInfo.InstallLocation))
                            {
                                if (!ScanFunctions.DirExists(progInfo.InstallLocation) &&
                                    !ScanFunctions.FileExists(progInfo.InstallLocation))
                                {
                                    if (!Wizard.IsOnIgnoreList(progInfo.InstallLocation))
                                    {
                                        Wizard.StoreInvalidKey(Strings.InvalidFile, regKey2.ToString(),
                                                               "InstallLocation");
                                    }
                                }
                            }

                            // Check install source
                            if (!string.IsNullOrEmpty(progInfo.InstallSource))
                            {
                                if (!ScanFunctions.DirExists(progInfo.InstallSource) &&
                                    !ScanFunctions.FileExists(progInfo.InstallSource))
                                {
                                    if (!Wizard.IsOnIgnoreList(progInfo.InstallSource))
                                    {
                                        Wizard.StoreInvalidKey(Strings.InvalidFile, regKey2.ToString(), "InstallSource");
                                    }
                                }
                            }

                            // Check ARP Cache
                            if (!progInfo.SlowCache)
                            {
                                continue;
                            }

                            if (string.IsNullOrEmpty(progInfo.FileName))
                            {
                                continue;
                            }

                            if (!ScanFunctions.FileExists(progInfo.FileName) && !Wizard.IsOnIgnoreList(progInfo.FileName))
                            {
                                Wizard.StoreInvalidKey(Strings.InvalidRegKey, progInfo.SlowInfoCacheRegKey);
                            }
                        }
                    }
                }

                Wizard.Report.WriteLine("Verifying registry entries in Add/Remove Cache");

                CheckArpCache(
                    Registry.LocalMachine.OpenSubKey(
                        @"SOFTWARE\Microsoft\Windows\CurrentVersion\App Management\ARPCache\"));
                CheckArpCache(
                    Registry.CurrentUser.OpenSubKey(
                        @"SOFTWARE\Microsoft\Windows\CurrentVersion\App Management\ARPCache\"));
            }
            catch (SecurityException ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }