Пример #1
0
        public override CommandResult Execute(CommandResult pipeIn)
        {
            // Obtain parameters
            bool   includeHidden = _arguments.Get <BoolArgument>("Force").Value;
            string path          = _arguments.Get <StringArgument>("Path").Value;
            bool   recurse       = _arguments.Get <BoolArgument>("Recurse").Value;
            int    depth         = _arguments.Get <IntegerArgument>("Depth").Value;
            string searchPattern = _arguments.Get <StringArgument>("Include").Value;

            // Registry:
            //     HKLM:\
            //     HKCU:\
            //     HKCR:\
            //     HKU:\
            RegistryKey root = ProviderHelper.GetRegistryKey(ref path);

            if (root != null)
            {
                _results = BrowseRegistry(root, path, includeHidden);
            }

            // Environment
            //     env:
            //     env:systemroot
            else if (path.ToUpperInvariant().StartsWith("ENV"))
            {
                _results = BrowseEnvironment(path);
            }

            // Filesystem:
            //     \
            //     ..\
            //     D:\
            else
            {
                _results = BrowseFilesystem(path, recurse, depth, includeHidden, searchPattern);
            }

            return(_results);
        }