Esempio n. 1
0
        /// <summary>
        /// Targets the specified namespace on a specified computer, and scavenges it for all classes, if the bool is set to true. If false, it is used to setup the ManagementPath which
        /// consists of the specified system and specified namespace
        /// </summary>
        /// <param name="pNamespace"></param>
        /// <param name="pHostName"></param>
        public WmiInformationGatherer(string pNamespace, string pHostName, bool pScavenge)
        {
            mRemoteWmiPath = new ManagementPath(@"\\" + pHostName + @"\root\" + pNamespace);

            if (pScavenge)
            {
                try
                {
                    ManagementClass managementClass = new ManagementClass(mRemoteWmiPath);
                    EnumerationOptions scavengeOptions = new EnumerationOptions();
                    scavengeOptions.EnumerateDeep = false;
                    WmiResults = new WmiResult(pHostName);
                    WmiResults.PopulateClassesList(managementClass.GetSubclasses());
                }
                catch (Exception e)
                {
                    WmiResults.WmiError = e;
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Targets the specified namespace on a specified computer, and scavenges it for all classes, if the bool is set to true. If false, it is used to setup the ManagementPath which
        /// consists of the specified system and specified namespace
        /// </summary>
        /// <param name="pNamespace"></param>
        /// <param name="pHostName"></param>
        public WmiInformationGatherer(string pNamespace, string pHostName, bool pScavenge)
        {
            mRemoteWmiPath = new ManagementPath(@"\\" + pHostName + @"\root\" + pNamespace);

            if (pScavenge)
            {
                try
                {
                    ManagementClass    managementClass = new ManagementClass(mRemoteWmiPath);
                    EnumerationOptions scavengeOptions = new EnumerationOptions();
                    scavengeOptions.EnumerateDeep = false;
                    WmiResults = new WmiResult(pHostName);
                    WmiResults.PopulateClassesList(managementClass.GetSubclasses());
                }
                catch (Exception e)
                {
                    WmiResults.WmiError = e;
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// This C'tor will query a specified system for all available namespaces under WBEM\Root. A singular remote host can be specified.
        /// If any errors occur, they will be placed in the public variable WmiResult.WmiError object, which is publically accessable here. Please use that obect for error handling.
        /// </summary>
        public WmiInformationGatherer(string pRemoteHost)
        {
            if (pRemoteHost == "" || pRemoteHost == "127.0.0.1" || pRemoteHost == "localhost" || pRemoteHost == "::1")
            {
                pRemoteHost = "localhost";
            }

            try
            {
                WmiResults = new WmiResult(pRemoteHost);
                mObjectQuery = new ObjectQuery("select * from __Namespace");
                mObjectSearcher = new ManagementObjectSearcher(new ManagementScope(new ManagementPath(@"\\" + pRemoteHost + @"\root")), mObjectQuery);
                ManagementObjectCollection gatheredNamespaces = mObjectSearcher.Get();
                ManagementObjectCollection.ManagementObjectEnumerator namespaceEnumerator = gatheredNamespaces.GetEnumerator();
                WmiResults.PopulateNamespaceList(gatheredNamespaces);
            }
            catch (Exception e)
            {
                WmiResults.WmiError = e;
            }
        }
Esempio n. 4
0
        /// <summary>
        /// This C'tor will query a specified system for all available namespaces under WBEM\Root. A singular remote host can be specified.
        /// If any errors occur, they will be placed in the public variable WmiResult.WmiError object, which is publically accessable here. Please use that obect for error handling.
        /// </summary>
        public WmiInformationGatherer(string pRemoteHost)
        {
            if (pRemoteHost == "" || pRemoteHost == "127.0.0.1" || pRemoteHost == "localhost" || pRemoteHost == "::1")
            {
                pRemoteHost = "localhost";
            }

            try
            {
                WmiResults      = new WmiResult(pRemoteHost);
                mObjectQuery    = new ObjectQuery("select * from __Namespace");
                mObjectSearcher = new ManagementObjectSearcher(new ManagementScope(new ManagementPath(@"\\" + pRemoteHost + @"\root")), mObjectQuery);
                ManagementObjectCollection gatheredNamespaces = mObjectSearcher.Get();
                ManagementObjectCollection.ManagementObjectEnumerator namespaceEnumerator = gatheredNamespaces.GetEnumerator();
                WmiResults.PopulateNamespaceList(gatheredNamespaces);
            }
            catch (Exception e)
            {
                WmiResults.WmiError = e;
            }
        }