コード例 #1
0
        public Dictionary <string, string> getDriveWithBootConfigurationDataStore()
        {
            var driveAndUniqueIdentifier = new Dictionary <string, string>();

            foreach (var drive in GetLogicalDrives())
            {
                var operation = new ExecutableOperation
                {
                    Command = "bcdedit", Arguments = "/store " + drive + "boot\\bcd"
                };
                var executableResult = _execProcess.Run(operation.Command, operation.Arguments);

                if (!executableResult.Output.Value().Contains(WINDOWS_BOOT_LOADER_TEXT))
                {
                    continue;
                }

                _logger.Log(String.Format("Windows Boot Loader Drive: {0}", drive));
                driveAndUniqueIdentifier.Add(DRIVE_KEY, drive);
                var uniqueIdentifier = getWindowsBootLoaderUniqueIdentifer
                                           (executableResult.Output.Value());
                _logger.Log(String.Format("Windows Boot Loader Unique Identifier: {0}", uniqueIdentifier));
                driveAndUniqueIdentifier.Add(UNIQUE_IDENTIFIER_KEY, uniqueIdentifier);
                break;
            }
            if (!driveAndUniqueIdentifier.ContainsKey(DRIVE_KEY) ||
                !driveAndUniqueIdentifier.ContainsKey(UNIQUE_IDENTIFIER_KEY) ||
                String.IsNullOrEmpty(driveAndUniqueIdentifier[DRIVE_KEY]) ||
                String.IsNullOrEmpty(driveAndUniqueIdentifier[UNIQUE_IDENTIFIER_KEY]))
            {
                throw new UnsuccessfulCommandExecutionException
                          ("BCD boot configuration data store not present",
                          new ExecutableResult {
                    ExitCode = "0"
                });
            }
            return(driveAndUniqueIdentifier);
        }
        public Dictionary<string, string> getDriveWithBootConfigurationDataStore()
        {
            var driveAndUniqueIdentifier = new Dictionary<string, string>();
            foreach (var drive in GetLogicalDrives())
            {
                var operation = new ExecutableOperation
                { Command = "bcdedit", Arguments = "/store " + drive + "boot\\bcd" };
                var executableResult = _execProcess.Run(operation.Command, operation.Arguments);

                if (!executableResult.Output.Value().Contains(WINDOWS_BOOT_LOADER_TEXT))
                    continue;

                _logger.Log(String.Format("Windows Boot Loader Drive: {0}", drive));
                driveAndUniqueIdentifier.Add(DRIVE_KEY, drive);
                var uniqueIdentifier = getWindowsBootLoaderUniqueIdentifer
                    (executableResult.Output.Value());
                _logger.Log(String.Format("Windows Boot Loader Unique Identifier: {0}", uniqueIdentifier));
                driveAndUniqueIdentifier.Add(UNIQUE_IDENTIFIER_KEY, uniqueIdentifier);
                break;
            }
            if(!driveAndUniqueIdentifier.ContainsKey(DRIVE_KEY) ||
                !driveAndUniqueIdentifier.ContainsKey(UNIQUE_IDENTIFIER_KEY) ||
                String.IsNullOrEmpty(driveAndUniqueIdentifier[DRIVE_KEY]) ||
                String.IsNullOrEmpty(driveAndUniqueIdentifier[UNIQUE_IDENTIFIER_KEY]))
                throw new UnsuccessfulCommandExecutionException
                    ("BCD boot configuration data store not present",
                    new ExecutableResult{ExitCode = "0"});
            return driveAndUniqueIdentifier;
        }