├── .gitattributes ├── .gitignore ├── LICENSE.md ├── README.md ├── WmiExplorer.sln └── WmiExplorer ├── ChangeLog.txt ├── Classes ├── Enums.cs ├── Helpers.cs ├── ListViewColumnSorter.cs ├── ListViewExtensions.cs ├── ManagementBaseObjectPropertyDescriptor.cs ├── ManagementBaseObjectW.cs ├── ManagementBaseObjectWConverter.cs ├── ManagementObjectW.cs ├── MouseWheelMessageFilter.cs ├── NativeMethods.cs ├── ObserverHandler.cs ├── ToolStripItemCollectionSorter.cs ├── Utilities.cs ├── WindowPlacement.cs ├── WmiClass.cs ├── WmiInstance.cs ├── WmiMethod.cs ├── WmiNamespace.cs └── WmiNode.cs ├── Forms ├── Form_About.Designer.cs ├── Form_About.cs ├── Form_About.resx ├── Form_ConnectAs.Designer.cs ├── Form_ConnectAs.cs ├── Form_ConnectAs.resx ├── Form_DisplayText.Designer.cs ├── Form_DisplayText.cs ├── Form_DisplayText.resx ├── Form_ExecMethod.Designer.cs ├── Form_ExecMethod.cs ├── Form_ExecMethod.resx ├── Form_Settings.Designer.cs ├── Form_Settings.cs ├── Form_Settings.resx ├── Form_ShowMof.Designer.cs ├── Form_ShowMof.cs ├── Form_ShowMof.resx ├── Form_Update.Designer.cs ├── Form_Update.cs └── Form_Update.resx ├── Icons ├── Database CMYK .ico └── Icojam-Blue-Bits-Database-search.ico ├── Program.cs ├── Properties ├── AssemblyInfo.cs ├── Resources.Designer.cs ├── Resources.resx ├── Settings.Designer.cs └── Settings.settings ├── Sms ├── SmsClient.cs ├── SmsClientAction.cs └── SmsClientActions.cs ├── Updater ├── Update.cs ├── UpdateEnums.cs └── UpdaterService.cs ├── WmiExplorer.Designer.cs ├── WmiExplorer.Functions.Designer.cs ├── WmiExplorer.cs ├── WmiExplorer.csproj ├── WmiExplorer.resx ├── app.config ├── releases.azure.xml └── releases.xml /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | [Xx]64/ 19 | [Xx]86/ 20 | [Bb]uild/ 21 | bld/ 22 | [Bb]in/ 23 | [Oo]bj/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | artifacts/ 46 | 47 | *_i.c 48 | *_p.c 49 | *_i.h 50 | *.ilk 51 | *.meta 52 | *.obj 53 | *.pch 54 | *.pdb 55 | *.pgc 56 | *.pgd 57 | *.rsp 58 | *.sbr 59 | *.tlb 60 | *.tli 61 | *.tlh 62 | *.tmp 63 | *.tmp_proj 64 | *.log 65 | *.vspscc 66 | *.vssscc 67 | .builds 68 | *.pidb 69 | *.svclog 70 | *.scc 71 | 72 | # Chutzpah Test files 73 | _Chutzpah* 74 | 75 | # Visual C++ cache files 76 | ipch/ 77 | *.aps 78 | *.ncb 79 | *.opendb 80 | *.opensdf 81 | *.sdf 82 | *.cachefile 83 | *.VC.db 84 | 85 | # Visual Studio profiler 86 | *.psess 87 | *.vsp 88 | *.vspx 89 | *.sap 90 | 91 | # TFS 2012 Local Workspace 92 | $tf/ 93 | 94 | # Guidance Automation Toolkit 95 | *.gpState 96 | 97 | # ReSharper is a .NET coding add-in 98 | _ReSharper*/ 99 | *.[Rr]e[Ss]harper 100 | *.DotSettings.user 101 | 102 | # JustCode is a .NET coding add-in 103 | .JustCode 104 | 105 | # TeamCity is a build add-in 106 | _TeamCity* 107 | 108 | # DotCover is a Code Coverage Tool 109 | *.dotCover 110 | 111 | # NCrunch 112 | _NCrunch_* 113 | .*crunch*.local.xml 114 | nCrunchTemp_* 115 | 116 | # MightyMoose 117 | *.mm.* 118 | AutoTest.Net/ 119 | 120 | # Web workbench (sass) 121 | .sass-cache/ 122 | 123 | # Installshield output folder 124 | [Ee]xpress/ 125 | 126 | # DocProject is a documentation generator add-in 127 | DocProject/buildhelp/ 128 | DocProject/Help/*.HxT 129 | DocProject/Help/*.HxC 130 | DocProject/Help/*.hhc 131 | DocProject/Help/*.hhk 132 | DocProject/Help/*.hhp 133 | DocProject/Help/Html2 134 | DocProject/Help/html 135 | 136 | # Click-Once directory 137 | publish/ 138 | 139 | # Publish Web Output 140 | *.[Pp]ublish.xml 141 | *.azurePubxml 142 | 143 | # TODO: Un-comment the next line if you do not want to checkin 144 | # your web deploy settings because they may include unencrypted 145 | # passwords 146 | #*.pubxml 147 | *.publishproj 148 | 149 | # NuGet Packages 150 | *.nupkg 151 | # The packages folder can be ignored because of Package Restore 152 | **/packages/* 153 | # except build/, which is used as an MSBuild target. 154 | !**/packages/build/ 155 | # Uncomment if necessary however generally it will be regenerated when needed 156 | #!**/packages/repositories.config 157 | # NuGet v3's project.json files produces more ignoreable files 158 | *.nuget.props 159 | *.nuget.targets 160 | 161 | # Microsoft Azure Build Output 162 | csx/ 163 | *.build.csdef 164 | 165 | # Microsoft Azure Emulator 166 | ecf/ 167 | rcf/ 168 | 169 | # Microsoft Azure ApplicationInsights config file 170 | ApplicationInsights.config 171 | 172 | # Windows Store app package directory 173 | AppPackages/ 174 | BundleArtifacts/ 175 | 176 | # Visual Studio cache files 177 | # files ending in .cache can be ignored 178 | *.[Cc]ache 179 | # but keep track of directories ending in .cache 180 | !*.[Cc]ache/ 181 | 182 | # Others 183 | ClientBin/ 184 | [Ss]tyle[Cc]op.* 185 | ~$* 186 | *~ 187 | *.dbmdl 188 | *.dbproj.schemaview 189 | *.pfx 190 | *.publishsettings 191 | node_modules/ 192 | orleans.codegen.cs 193 | 194 | # RIA/Silverlight projects 195 | Generated_Code/ 196 | 197 | # Backup & report files from converting an old project file 198 | # to a newer Visual Studio version. Backup files are not needed, 199 | # because we have git ;-) 200 | _UpgradeReport_Files/ 201 | Backup*/ 202 | UpgradeLog*.XML 203 | UpgradeLog*.htm 204 | 205 | # SQL Server files 206 | *.mdf 207 | *.ldf 208 | 209 | # Business Intelligence projects 210 | *.rdl.data 211 | *.bim.layout 212 | *.bim_*.settings 213 | 214 | # Microsoft Fakes 215 | FakesAssemblies/ 216 | 217 | # GhostDoc plugin setting file 218 | *.GhostDoc.xml 219 | 220 | # Node.js Tools for Visual Studio 221 | .ntvs_analysis.dat 222 | 223 | # Visual Studio 6 build log 224 | *.plg 225 | 226 | # Visual Studio 6 workspace options file 227 | *.opt 228 | 229 | # Visual Studio LightSwitch build output 230 | **/*.HTMLClient/GeneratedArtifacts 231 | **/*.DesktopClient/GeneratedArtifacts 232 | **/*.DesktopClient/ModelManifest.xml 233 | **/*.Server/GeneratedArtifacts 234 | **/*.Server/ModelManifest.xml 235 | _Pvt_Extensions 236 | 237 | # LightSwitch generated files 238 | GeneratedArtifacts/ 239 | ModelManifest.xml 240 | 241 | # Paket dependency manager 242 | .paket/paket.exe 243 | 244 | # FAKE - F# Make 245 | .fake/ -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 vinaypamnani 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Download: https://git.io/wmie2 2 | 3 | 4 | WMI Explorer is a utility intended to provide the ability to browse and view WMI namespaces/classes/instances/properties in a single pane of view and is inspired by the PowerShell based WMI Explorer written by Marc. 5 | 6 | As someone who works with Configuration Manager (SCCM), I spend a lot of time in wbemtest trying to find things which is very time consuming. I started this project with the intention to combine the features of currently available WMI Explorers, and to make it easier and quicker to find what you're looking for in WMI. 7 | 8 | # Requirements 9 | 10 | * Microsoft .NET Framework 4.0 Full or .NET Framework 4.5.1 11 | * Minimum display resolution: 1024x768 12 | * Administrator rights to view some WMI objects 13 | * (Optional) Internet access for automatic update check 14 | 15 | # Features 16 | 17 | * Browse and view WMI objects in a single pane of view. 18 | * Connect as alternate credentials to remote computers. 19 | * Asynchronous and Synchronous mode for enumeration. 20 | * Method execution. 21 | * SMS (Configuration Manager) mode providing additional functionality for Configuration Manager. 22 | * Filter classes and instances matching specified criteria. 23 | * View classes/instances in Managed Object Format (MOF). 24 | * Search classes, methods and properties for names matching specified criteria. 25 | * Run WQL queries. 26 | * Automatic generation of WQL query for the selected Class/Instance. 27 | * Automatic script creation (PowerShell and VBS). 28 | * Highlighting enumerated objects. 29 | * Display property descriptions and possible enumeration values (if available). 30 | * Display methods descriptions and parameters. 31 | * Display embedded property values. 32 | * Caching enumerated classes/instances. 33 | * View WMI Provider Process Information. 34 | * Automatic check for new version. 35 | 36 | # Known Issues 37 | 38 | * Asynchronous mode currently applies only for Class and Instance enumeration. Search and Query execution is synchronous. 39 | * Cached instance is not updated after clicking on ‘Refresh Object’. 40 | * root\directory\LDAP namespace is excluded from Search because enumeration of objects in this namespace can take a very long time and can even return "Quota Violation" error. 41 | * Scripting: PowerShell script execution through WMI Explorer requires PowerShell v2. 42 | * Method Execution: Methods requiring input parameters of Object or Reference data type are currently not supported. 43 | -------------------------------------------------------------------------------- /WmiExplorer.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.30723.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WmiExplorer", "WmiExplorer\WmiExplorer.csproj", "{781647DE-1788-4B7C-9289-D0323FDF562A}" 7 | EndProject 8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B9BD9632-8046-4414-B261-35222239F891}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {781647DE-1788-4B7C-9289-D0323FDF562A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {781647DE-1788-4B7C-9289-D0323FDF562A}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {781647DE-1788-4B7C-9289-D0323FDF562A}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {781647DE-1788-4B7C-9289-D0323FDF562A}.Release|Any CPU.Build.0 = Release|Any CPU 20 | EndGlobalSection 21 | GlobalSection(SolutionProperties) = preSolution 22 | HideSolutionNode = FALSE 23 | EndGlobalSection 24 | EndGlobal 25 | -------------------------------------------------------------------------------- /WmiExplorer/ChangeLog.txt: -------------------------------------------------------------------------------- 1 | Version 2.0.0.2 [10-05-2017] 2 | 3 | * Migration to GitHub. 4 | * Added option to specify COMPUTERNAME as a parameter and automatically connect. 5 | Example: WmiExplorer.exe COMPUTERNAME 6 | 7 | Version 2.0.0.0 [10-27-2014] 8 | 9 | * New: Asynchronous mode for enumeration of classes and instances in the background. 10 | * New: Method execution. 11 | * New: SMS (System Center Configuration Manager) Mode. 12 | * New: Property tab showing properties of selected class. 13 | * New: Input & Output parameter information in Methods tab with Help information. 14 | * New: List View output mode for Query Results. 15 | * New: Update Notifications when a new version of WMI Explorer is available. 16 | * New: Connect to multiple computers at the same time. 17 | * New: Quick Filter for Classes and Instances. 18 | * New: User Preferences. 19 | * New: View WMI Provider Process Information. 20 | * Improved: UI display on higher scaling levels and resolution. 21 | * Improved: Connect As option to provide alternate credentials. 22 | * Improved: Display of embedded object names in Property Grid. 23 | 24 | 25 | Version 1.0.0.8 [01-07-2014] 26 | 27 | * BugFix: Fixed a crash that occurs due to use of incorrectly displayed right-click context menu when no items are selected in Class/Instance list view. 28 | 29 | 30 | Version 1.0.0.7 [01-07-2014] 31 | 32 | * Initial Release. -------------------------------------------------------------------------------- /WmiExplorer/Classes/Enums.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Drawing; 3 | 4 | namespace WmiExplorer.Classes 5 | { 6 | public enum MessageCategory 7 | { 8 | Unknown, 9 | Info, 10 | Action, 11 | Warn, 12 | Error, 13 | Cache, 14 | Sms, 15 | None, 16 | } 17 | 18 | [Flags] 19 | public enum EnumOptions 20 | { 21 | None = 0, 22 | IncludeSystem = 1, 23 | IncludeCim = 2, 24 | IncludePerf = 4, 25 | IncludeMsft = 8, 26 | ShowNullInstanceValues = 16, 27 | ShowSystemProperties = 32, 28 | ExcludeSmsCollections = 64, 29 | ExcludeSmsInventory = 128 30 | } 31 | 32 | public static class ColorCategory 33 | { 34 | public static Color Unknown = Color.Gold; 35 | public static Color Info = Color.YellowGreen; 36 | public static Color Action = Color.Khaki; 37 | public static Color Warn = Color.Yellow; 38 | public static Color Error = Color.Red; 39 | public static Color Cache = Color.LightGreen; 40 | public static Color Sms = Color.LightSkyBlue; 41 | public static Color None = Color.Empty; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /WmiExplorer/Classes/Helpers.cs: -------------------------------------------------------------------------------- 1 | using System.Drawing; 2 | using System.Management; 3 | using System.Windows.Forms; 4 | using WmiExplorer.Sms; 5 | 6 | namespace WmiExplorer.Classes 7 | { 8 | public static class Helpers 9 | { 10 | public static Form CenterForm(this Form child, Form parent) 11 | { 12 | child.StartPosition = FormStartPosition.Manual; 13 | child.Location = new Point(parent.Location.X + (parent.Width - child.Width) / 2, parent.Location.Y + (parent.Height - child.Height) / 2); 14 | return child; 15 | } 16 | 17 | public static TreeNode GetRootNode(this TreeNode treeNode) 18 | { 19 | var rootNode = treeNode; 20 | 21 | while (rootNode.Parent != null) 22 | { 23 | rootNode = rootNode.Parent; 24 | } 25 | 26 | return rootNode; 27 | } 28 | 29 | public static ConnectionOptions GetRootNodeCredentials(TreeNode treeNode) 30 | { 31 | var rootNode = treeNode.GetRootNode(); 32 | return ((WmiNode)rootNode.Tag).Connection; 33 | } 34 | 35 | public static SmsClient GetSmsClient(TreeNode treeNode) 36 | { 37 | var rootNode = treeNode; 38 | 39 | while (rootNode.Parent != null) 40 | { 41 | rootNode = rootNode.Parent; 42 | } 43 | 44 | return ((WmiNode)rootNode.Tag).SmsClient; 45 | } 46 | 47 | public static bool IsNodeDisconnected(TreeNode treeNode) 48 | { 49 | WmiNode wmiNode = treeNode.Tag as WmiNode; 50 | if (wmiNode != null && wmiNode.IsRootNode && wmiNode.IsConnected == false) 51 | return true; 52 | 53 | return false; 54 | } 55 | 56 | 57 | } 58 | } -------------------------------------------------------------------------------- /WmiExplorer/Classes/ListViewColumnSorter.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Windows.Forms; 3 | 4 | namespace WmiExplorer.Classes 5 | { 6 | // How to sort a ListView control by a column in Visual C# 7 | // http://support.microsoft.com/kb/319401 8 | 9 | internal class ListViewColumnSorter : IComparer 10 | { 11 | /// 12 | /// Specifies the column to be sorted 13 | /// 14 | private int _columnToSort; 15 | 16 | /// 17 | /// Specifies the order in which to sort (i.e. 'Ascending'). 18 | /// 19 | private SortOrder _orderOfSort; 20 | 21 | /// 22 | /// Case insensitive comparer object 23 | /// 24 | private readonly CaseInsensitiveComparer _objectCompare; 25 | 26 | /// 27 | /// Class constructor. Initializes various elements 28 | /// 29 | public ListViewColumnSorter() 30 | { 31 | // Initialize the column to '0' 32 | _columnToSort = 0; 33 | 34 | // Initialize the sort order to 'none' 35 | _orderOfSort = SortOrder.None; 36 | 37 | // Initialize the CaseInsensitiveComparer object 38 | _objectCompare = new CaseInsensitiveComparer(); 39 | } 40 | 41 | /// 42 | /// This method is inherited from the IComparer interface. It compares the two objects passed using a case insensitive comparison. 43 | /// 44 | /// First object to be compared 45 | /// Second object to be compared 46 | /// The result of the comparison. "0" if equal, negative if 'x' is less than 'y' and positive if 'x' is greater than 'y' 47 | public int Compare(object x, object y) 48 | { 49 | // Cast the objects to be compared to ListViewItem objects 50 | ListViewItem listviewX = (ListViewItem)x; 51 | ListViewItem listviewY = (ListViewItem)y; 52 | 53 | // Compare the two items 54 | var compareResult = _objectCompare.Compare(listviewX.SubItems[_columnToSort].Text, listviewY.SubItems[_columnToSort].Text); 55 | 56 | // Calculate correct return value based on object comparison 57 | if (_orderOfSort == SortOrder.Ascending) 58 | { 59 | // Ascending sort is selected, return normal result of compare operation 60 | return compareResult; 61 | } 62 | 63 | if (_orderOfSort == SortOrder.Descending) 64 | { 65 | // Descending sort is selected, return negative result of compare operation 66 | return (-compareResult); 67 | } 68 | 69 | // Return '0' to indicate they are equal 70 | return 0; 71 | } 72 | 73 | /// 74 | /// Gets or sets the number of the column to which to apply the sorting operation (Defaults to '0'). 75 | /// 76 | public int SortColumn 77 | { 78 | set 79 | { 80 | _columnToSort = value; 81 | } 82 | get 83 | { 84 | return _columnToSort; 85 | } 86 | } 87 | 88 | /// 89 | /// Gets or sets the order of sorting to apply (for example, 'Ascending' or 'Descending'). 90 | /// 91 | public SortOrder Order 92 | { 93 | set 94 | { 95 | _orderOfSort = value; 96 | } 97 | get 98 | { 99 | return _orderOfSort; 100 | } 101 | } 102 | } 103 | } -------------------------------------------------------------------------------- /WmiExplorer/Classes/ListViewExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | using System.Windows.Forms; 4 | 5 | // ReSharper disable InconsistentNaming 6 | // ReSharper disable UnusedMember.Local 7 | 8 | namespace WmiExplorer.Classes 9 | { 10 | // Sort listview Columns and Set Sort Arrow Icon on Column Header 11 | // http://www.codeproject.com/Tips/734463/Sort-listview-Columns-and-Set-Sort-Arrow-Icon-on-C 12 | internal static class ListViewExtensions 13 | { 14 | [StructLayout(LayoutKind.Sequential)] 15 | public struct LVCOLUMN 16 | { 17 | public Int32 mask; 18 | public Int32 cx; 19 | 20 | [MarshalAs(UnmanagedType.LPTStr)] 21 | public string pszText; 22 | 23 | public IntPtr hbm; 24 | public Int32 cchTextMax; 25 | public Int32 fmt; 26 | public Int32 iSubItem; 27 | public Int32 iImage; 28 | public Int32 iOrder; 29 | } 30 | 31 | private const Int32 HDI_WIDTH = 0x0001; 32 | private const Int32 HDI_HEIGHT = HDI_WIDTH; 33 | private const Int32 HDI_TEXT = 0x0002; 34 | private const Int32 HDI_FORMAT = 0x0004; 35 | private const Int32 HDI_LPARAM = 0x0008; 36 | private const Int32 HDI_BITMAP = 0x0010; 37 | private const Int32 HDI_IMAGE = 0x0020; 38 | private const Int32 HDI_DI_SETITEM = 0x0040; 39 | private const Int32 HDI_ORDER = 0x0080; 40 | private const Int32 HDI_FILTER = 0x0100; 41 | 42 | private const Int32 HDF_LEFT = 0x0000; 43 | private const Int32 HDF_RIGHT = 0x0001; 44 | private const Int32 HDF_CENTER = 0x0002; 45 | private const Int32 HDF_JUSTIFYMASK = 0x0003; 46 | private const Int32 HDF_RTLREADING = 0x0004; 47 | private const Int32 HDF_OWNERDRAW = 0x8000; 48 | private const Int32 HDF_STRING = 0x4000; 49 | private const Int32 HDF_BITMAP = 0x2000; 50 | private const Int32 HDF_BITMAP_ON_RIGHT = 0x1000; 51 | private const Int32 HDF_IMAGE = 0x0800; 52 | private const Int32 HDF_SORTUP = 0x0400; 53 | private const Int32 HDF_SORTDOWN = 0x0200; 54 | 55 | private const Int32 LVM_FIRST = 0x1000; // List messages 56 | private const Int32 LVM_GETHEADER = LVM_FIRST + 31; 57 | private const Int32 HDM_FIRST = 0x1200; // Header messages 58 | private const Int32 HDM_SETIMAGELIST = HDM_FIRST + 8; 59 | private const Int32 HDM_GETIMAGELIST = HDM_FIRST + 9; 60 | private const Int32 HDM_GETITEM = HDM_FIRST + 11; 61 | private const Int32 HDM_SETITEM = HDM_FIRST + 12; 62 | 63 | //This method is used to set arrow icon 64 | public static void SetSortIcon(this ListView listView, int columnIndex, SortOrder order) 65 | { 66 | IntPtr columnHeader = NativeMethods.SendMessage(listView.Handle, LVM_GETHEADER, IntPtr.Zero, IntPtr.Zero); 67 | 68 | for (int columnNumber = 0; columnNumber <= listView.Columns.Count - 1; columnNumber++) 69 | { 70 | IntPtr columnPtr = new IntPtr(columnNumber); 71 | LVCOLUMN lvColumn = new LVCOLUMN(); 72 | lvColumn.mask = HDI_FORMAT; 73 | 74 | NativeMethods.SendMessageLVCOLUMN(columnHeader, HDM_GETITEM, columnPtr, ref lvColumn); 75 | 76 | if (!(order == SortOrder.None) && columnNumber == columnIndex) 77 | { 78 | switch (order) 79 | { 80 | case SortOrder.Ascending: 81 | lvColumn.fmt &= ~HDF_SORTDOWN; 82 | lvColumn.fmt |= HDF_SORTUP; 83 | break; 84 | 85 | case SortOrder.Descending: 86 | lvColumn.fmt &= ~HDF_SORTUP; 87 | lvColumn.fmt |= HDF_SORTDOWN; 88 | break; 89 | } 90 | lvColumn.fmt |= (HDF_LEFT | HDF_BITMAP_ON_RIGHT); 91 | } 92 | else 93 | { 94 | lvColumn.fmt &= ~HDF_SORTDOWN & ~HDF_SORTUP & ~HDF_BITMAP_ON_RIGHT; 95 | } 96 | 97 | NativeMethods.SendMessageLVCOLUMN(columnHeader, HDM_SETITEM, columnPtr, ref lvColumn); 98 | } 99 | } 100 | 101 | // Reference link: 102 | // http://stackoverflow.com/questions/14133225/listview-autoresizecolumns-based-on-both-column-content-and-header 103 | // Reference link 104 | public static void ResizeColumns(this ListView lv) 105 | { 106 | //lv.AutoResizeColumns(lv.Items.Count > 0 107 | // ? ColumnHeaderAutoResizeStyle.ColumnContent 108 | // : ColumnHeaderAutoResizeStyle.HeaderSize); 109 | 110 | lv.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); 111 | lv.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); 112 | 113 | //lv.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); 114 | //ListView.ColumnHeaderCollection cc = lv.Columns; 115 | //for (int i = 0; i < cc.Count; i++) 116 | //{ 117 | // int colWidth = TextRenderer.MeasureText(cc[i].Text, lv.Font).Width + 10; 118 | // if (colWidth > cc[i].Width) 119 | // { 120 | // cc[i].Width = colWidth; 121 | // } 122 | //} 123 | } 124 | } 125 | } 126 | 127 | // ReSharper restore InconsistentNaming 128 | // ReSharper restore UnusedMember.Local -------------------------------------------------------------------------------- /WmiExplorer/Classes/ManagementBaseObjectPropertyDescriptor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | using System.Management; 4 | 5 | namespace WmiExplorer.Classes 6 | { 7 | /// 8 | /// Required for Implementation of ICustomTypeDescriptor 9 | /// Reference Links and Tutorials: 10 | /// http://www.codeproject.com/Articles/539202/CIMTool-for-Windows-Management-Instrumentation-Par 11 | /// http://www.codeproject.com/Articles/4448/Customized-display-of-collection-data-in-a-Propert 12 | /// http://msdn.microsoft.com/en-us/magazine/cc163816.aspx 13 | /// 14 | [TypeConverter(typeof(ManagementBaseObjectWConverter))] 15 | internal class ManagementBaseObjectPropertyDescriptor : PropertyDescriptor 16 | { 17 | protected string category; 18 | private readonly PropertyData _property; 19 | private readonly ManagementBaseObjectW _wrapperObject; 20 | 21 | public ManagementBaseObjectPropertyDescriptor(ManagementBaseObjectW actualObject, PropertyData property) 22 | : base(property.Name, null) 23 | { 24 | _wrapperObject = actualObject; 25 | _property = property; 26 | 27 | if (_property.Origin == "___SYSTEM") 28 | category = "System Properties"; 29 | else 30 | category = "Properties"; 31 | } 32 | 33 | public override string Category 34 | { 35 | get 36 | { 37 | return category; 38 | } 39 | } 40 | 41 | public override Type ComponentType 42 | { 43 | get 44 | { 45 | return _wrapperObject.GetType(); 46 | } 47 | } 48 | 49 | public override string Description 50 | { 51 | get 52 | { 53 | // Embedded instance 54 | if (_property.Value is ManagementBaseObject || _property.Type == CimType.Object) 55 | { 56 | string derivation; 57 | 58 | try 59 | { 60 | derivation = "Embedded " + _property.Qualifiers["CIMTYPE"].Value; 61 | } 62 | catch 63 | { 64 | derivation = "Embedded Object"; 65 | } 66 | 67 | return derivation; 68 | } 69 | 70 | string retVal = "Type - " + _property.Type; 71 | 72 | if (_property.IsArray) 73 | retVal += " []"; 74 | 75 | if (_property.Type == CimType.DateTime && _property.Value != null && !_property.IsArray) 76 | retVal = retVal + " - Normalized Value: " + GetNormalizedDate(_property); 77 | 78 | string pDesc = ""; 79 | try 80 | { 81 | ManagementClass mClass = new ManagementClass(_wrapperObject.ClassPath.Path); 82 | mClass.Options.UseAmendedQualifiers = true; 83 | 84 | foreach (QualifierData qd in mClass.Properties[_property.Name].Qualifiers) 85 | { 86 | if (qd.Name == "Description") 87 | pDesc = qd.Value.ToString(); 88 | 89 | if (qd.Name == "lazy") 90 | retVal += Environment.NewLine + "Lazy Property"; 91 | 92 | if (qd.Name == "enumeration") 93 | retVal += Environment.NewLine + "Enumeration: " + qd.Value; 94 | // TODO: Find other qualifier containing enumerations (Values, ValueMap) 95 | } 96 | } 97 | catch (Exception) 98 | { 99 | pDesc = ""; 100 | } 101 | 102 | if (pDesc != "") 103 | retVal += Environment.NewLine + pDesc; 104 | 105 | return retVal; 106 | } 107 | } 108 | 109 | public override string DisplayName 110 | { 111 | get 112 | { 113 | string retVal = _property.Name; 114 | 115 | foreach (QualifierData q in _property.Qualifiers) 116 | { 117 | if (q.Name == "key") 118 | retVal = "*" + retVal; 119 | } 120 | 121 | return retVal; 122 | } 123 | } 124 | 125 | public override bool IsReadOnly 126 | { 127 | get 128 | { 129 | return true; 130 | } 131 | } 132 | 133 | public override Type PropertyType 134 | { 135 | get 136 | { 137 | return GetDotNetType(); 138 | } 139 | } 140 | 141 | public override bool CanResetValue(object component) 142 | { 143 | return false; 144 | } 145 | 146 | public Type GetDotNetType() 147 | { 148 | if ((_property.Type == CimType.Object) && (_property.Value is ManagementBaseObject)) 149 | { 150 | if (_property.Value is ManagementClass) 151 | { 152 | return typeof(ManagementClass); 153 | } 154 | 155 | if (_property.Value is ManagementObject) 156 | { 157 | return typeof(ManagementObject); 158 | } 159 | 160 | return typeof(ManagementBaseObject); 161 | } 162 | 163 | return ManagementBaseObjectW.GetTypeFor(_property.Type, _property.IsArray); 164 | } 165 | 166 | public override object GetValue(object component) 167 | { 168 | // To expand and display embedded instances, such as Props for SMS SCI classes. 169 | var val = ((ManagementBaseObjectW)component)[_property.Name]; 170 | 171 | if (val is ManagementBaseObject[]) 172 | { 173 | ManagementBaseObject[] props = (ManagementBaseObject[])val; 174 | ManagementBaseObjectW[] propvalues = new ManagementBaseObjectW[props.Length]; 175 | for (int i = 0; i < props.Length; i++) 176 | { 177 | propvalues[i] = new ManagementBaseObjectW(props[i]); 178 | } 179 | return propvalues; 180 | } 181 | 182 | if (val is ManagementBaseObject) 183 | { 184 | ManagementBaseObject props = (ManagementBaseObject)val; 185 | ManagementBaseObjectW propvalue = new ManagementBaseObjectW(props); 186 | return propvalue; 187 | } 188 | 189 | return val; 190 | } 191 | 192 | public override void ResetValue(object component) 193 | { 194 | } 195 | 196 | public override void SetValue(object component, object value) 197 | { 198 | ((ManagementBaseObjectW)component)[_property.Name] = value; 199 | } 200 | 201 | public override bool ShouldSerializeValue(object component) 202 | { 203 | return true; 204 | } 205 | 206 | protected static object GetNormalizedDate(PropertyData propertyData) 207 | { 208 | object retVal = propertyData.Value; 209 | 210 | if (propertyData.Type == CimType.DateTime && propertyData.Value != null) 211 | { 212 | //20080409032454.676631-420 213 | // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 214 | // Y 2 0 0 8 M 0 4 D 0 9 H 0 3 M 2 4 S 5 4 . m 6 7 6 6 3 1 U-420 215 | string dateString = propertyData.Value.ToString(); 216 | try 217 | { 218 | retVal = new DateTime( 219 | int.Parse(dateString.Substring(0, 4)), 220 | int.Parse(dateString.Substring(4, 2)), 221 | int.Parse(dateString.Substring(6, 2)), 222 | int.Parse(dateString.Substring(8, 2)), 223 | int.Parse(dateString.Substring(10, 2)), 224 | int.Parse(dateString.Substring(12, 2)), 225 | int.Parse(dateString.Substring(15, 6)) / 1000, DateTimeKind.Local); 226 | } 227 | catch (ArgumentOutOfRangeException) 228 | { 229 | retVal = dateString; 230 | } 231 | } 232 | 233 | return retVal; 234 | } 235 | } 236 | } -------------------------------------------------------------------------------- /WmiExplorer/Classes/ManagementBaseObjectWConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | using System.Globalization; 4 | using System.Management; 5 | 6 | namespace WmiExplorer.Classes 7 | { 8 | /// 9 | /// Used to display property values of Embedded WMI Objects. 10 | /// Reference tutorial: http://www.codeproject.com/Articles/4448/Customized-display-of-collection-data-in-a-Propert 11 | /// 12 | internal class ManagementBaseObjectWConverter : ExpandableObjectConverter 13 | { 14 | public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) 15 | { 16 | if (value is ManagementBaseObjectW) 17 | { 18 | ManagementBaseObjectW mObjectW = (ManagementBaseObjectW)value; 19 | 20 | // If PropertyName contains Name, return the value of the property 21 | foreach (PropertyData p in mObjectW.Properties) 22 | { 23 | if (p.Name.Contains("Name")) 24 | return p.Value.ToString(); 25 | } 26 | 27 | // No match on Name. If PropertyName contains ID, return the value of the property 28 | foreach (PropertyData p in mObjectW.Properties) 29 | { 30 | if (p.Name.Contains("ID")) 31 | return p.Value.ToString(); 32 | } 33 | 34 | // No match on Name or ID. If Property is key, return the value of the property 35 | foreach (PropertyData p in mObjectW.Properties) 36 | { 37 | foreach (QualifierData q in p.Qualifiers) 38 | if (q.Name.Equals("key", StringComparison.InvariantCultureIgnoreCase)) 39 | if (String.IsNullOrEmpty(p.Value.ToString())) 40 | return String.Empty; 41 | else 42 | return p.Value.ToString(); 43 | } 44 | 45 | // No matches. Return an empty string. 46 | return String.Empty; 47 | } 48 | 49 | return base.ConvertTo(context, culture, value, destinationType); 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /WmiExplorer/Classes/ManagementObjectW.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | using System.Management; 3 | 4 | namespace WmiExplorer.Classes 5 | { 6 | /// 7 | /// Wrapper Class for ManagementObject 8 | /// 9 | [TypeConverter(typeof(ManagementBaseObjectWConverter))] 10 | internal class ManagementObjectW : ManagementBaseObjectW 11 | { 12 | public ManagementObjectW(ManagementBaseObject actualObject) 13 | : base(actualObject) 14 | { 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /WmiExplorer/Classes/MouseWheelMessageFilter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Drawing; 3 | using System.Windows.Forms; 4 | 5 | namespace WmiExplorer.Classes 6 | { 7 | /// 8 | /// Used to allow scrolling for the controls, without having to select them or focus on them. 9 | /// http://www.brad-smith.info/blog/archives/635 10 | /// http://stackoverflow.com/questions/7852824/usercontrol-how-to-add-mousewheel-listener 11 | /// 12 | internal class MouseWheelMessageFilter : IMessageFilter 13 | { 14 | private const int WM_MOUSEWHEEL = 0x20a; 15 | 16 | public bool PreFilterMessage(ref Message m) 17 | { 18 | if (m.Msg == WM_MOUSEWHEEL) 19 | { 20 | // LParam contains the location of the mouse pointer 21 | Point pos = new Point(m.LParam.ToInt32() & 0xffff, m.LParam.ToInt32() >> 16); 22 | IntPtr hWnd = NativeMethods.WindowFromPoint(pos); 23 | if (hWnd != IntPtr.Zero && hWnd != m.HWnd && Control.FromHandle(hWnd) != null) 24 | { 25 | // redirect the message to the correct control 26 | NativeMethods.SendMessage(hWnd, m.Msg, m.WParam, m.LParam); 27 | return true; 28 | } 29 | } 30 | 31 | return false; 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /WmiExplorer/Classes/NativeMethods.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics.CodeAnalysis; 3 | using System.Drawing; 4 | using System.Runtime.InteropServices; 5 | 6 | namespace WmiExplorer.Classes 7 | { 8 | /// 9 | /// Wrapper for Native Methods 10 | /// 11 | internal class NativeMethods 12 | { 13 | // P/Invoke declarations 14 | 15 | [DllImport("user32.dll")] 16 | public static extern bool GetWindowPlacement(IntPtr hWnd, out WINDOWPLACEMENT lpwndpl); 17 | 18 | [DllImport("user32.dll")] 19 | public static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wp, IntPtr lp); 20 | 21 | [DllImport("user32.dll", EntryPoint = "SendMessage")] 22 | public static extern IntPtr SendMessageLVCOLUMN(IntPtr hWnd, Int32 Msg, IntPtr wParam, ref ListViewExtensions.LVCOLUMN lPLVCOLUMN); 23 | 24 | [DllImport("user32.dll")] 25 | public static extern bool SetWindowPlacement(IntPtr hWnd, [In] ref WINDOWPLACEMENT lpwndpl); 26 | 27 | [SuppressMessage("Microsoft.Portability", "CA1901:PInvokeDeclarationsShouldBePortable", MessageId = "0"), DllImport("user32.dll")] 28 | public static extern IntPtr WindowFromPoint(Point pt); 29 | } 30 | } -------------------------------------------------------------------------------- /WmiExplorer/Classes/ObserverHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Management; 4 | using System.Runtime.Caching; 5 | using System.Windows.Forms; 6 | 7 | namespace WmiExplorer.Classes 8 | { 9 | internal class ObserverHandler 10 | { 11 | private readonly bool _isClass; 12 | private readonly bool _isNamespace; 13 | private readonly Stopwatch _stopwatch = new Stopwatch(); 14 | private readonly WmiClass _wmiClass; 15 | private readonly WmiNamespace _wmiNamespace; 16 | 17 | /// 18 | /// Constructor for observer working on retrieving classes for a Namespace 19 | /// 20 | /// Instance of WmiNamespace for which to enumerate classes 21 | public ObserverHandler(WmiNamespace wmiNamespace) 22 | { 23 | _wmiNamespace = wmiNamespace; 24 | _wmiNamespace.IsEnumerating = true; 25 | _isNamespace = true; 26 | _stopwatch.Start(); 27 | } 28 | 29 | /// 30 | /// Constructor for observer working on retrieving instances for a Class 31 | /// 32 | /// Instance of WmiClass for which to enumerate instances 33 | public ObserverHandler(WmiClass wmiClass) 34 | { 35 | _wmiClass = wmiClass; 36 | _wmiClass.IsEnumerating = true; 37 | _isClass = true; 38 | _stopwatch.Start(); 39 | } 40 | 41 | public bool IsComplete { get; private set; } 42 | 43 | public void Done(object sender, CompletedEventArgs e) 44 | { 45 | _stopwatch.Stop(); 46 | 47 | if (_isNamespace) 48 | { 49 | if (e.Status == ManagementStatus.CallCanceled) 50 | { 51 | _wmiNamespace.IsPartiallyEnumerated = true; 52 | _wmiNamespace.IsEnumerationCancelled = true; 53 | } 54 | else 55 | { 56 | _wmiNamespace.IsPartiallyEnumerated = false; 57 | _wmiNamespace.IsEnumerationCancelled = false; 58 | } 59 | 60 | _wmiNamespace.IsEnumerated = true; 61 | _wmiNamespace.IsEnumerating = false; 62 | _wmiNamespace.EnumerationStatus = e.Status.ToString(); 63 | _wmiNamespace.EnumTime = DateTime.Now; 64 | _wmiNamespace.EnumTimeElapsed = _stopwatch.Elapsed; 65 | 66 | CacheItem ci = new CacheItem(_wmiNamespace.Path, _wmiNamespace.Classes); 67 | WmiExplorer.AppCache.Set(ci, WmiExplorer.CachePolicy); 68 | _wmiNamespace.ResetClasses(); 69 | } 70 | 71 | if (_isClass) 72 | { 73 | if (e.Status == ManagementStatus.CallCanceled) 74 | { 75 | _wmiClass.IsPartiallyEnumerated = true; 76 | _wmiClass.IsEnumerationCancelled = true; 77 | } 78 | else 79 | { 80 | _wmiClass.IsPartiallyEnumerated = false; 81 | _wmiClass.IsEnumerationCancelled = false; 82 | } 83 | 84 | _wmiClass.IsEnumerated = true; 85 | _wmiClass.IsEnumerating = false; 86 | _wmiClass.IsEnumerationCancelled = false; 87 | _wmiClass.EnumerationStatus = e.Status.ToString(); 88 | _wmiClass.EnumTime = DateTime.Now; 89 | _wmiClass.EnumTimeElapsed = _stopwatch.Elapsed; 90 | 91 | CacheItem ci = new CacheItem(_wmiClass.Path, _wmiClass.Instances); 92 | WmiExplorer.AppCache.Set(ci, WmiExplorer.CachePolicy); 93 | _wmiClass.ResetInstances(); 94 | } 95 | 96 | IsComplete = true; 97 | } 98 | 99 | public void NewObject(object sender, ObjectReadyEventArgs e) 100 | { 101 | ManagementObject mObject = (ManagementObject)e.NewObject; 102 | 103 | if (mObject.Path.IsClass && _isNamespace) 104 | { 105 | WmiClass wmiClass = new WmiClass(mObject as ManagementClass); 106 | 107 | ListViewItem li = new ListViewItem 108 | { 109 | Name = wmiClass.Path, 110 | Text = wmiClass.DisplayName, 111 | ToolTipText = wmiClass.Description, 112 | Tag = wmiClass 113 | }; 114 | 115 | // Add Lazy Properties, Description, and Path columns 116 | li.SubItems.Add(wmiClass.HasLazyProperties.ToString()); 117 | li.SubItems.Add(wmiClass.Description); 118 | li.SubItems.Add(wmiClass.Path); 119 | 120 | _wmiNamespace.AddClass(li); 121 | } 122 | 123 | if (mObject.Path.IsInstance && _isClass) 124 | { 125 | WmiInstance wmiInstance = new WmiInstance(mObject); 126 | 127 | ListViewItem li = new ListViewItem 128 | { 129 | Name = wmiInstance.Path, 130 | Text = wmiInstance.RelativePath, 131 | ToolTipText = wmiInstance.RelativePath, 132 | Tag = wmiInstance 133 | }; 134 | 135 | _wmiClass.AddInstance(li); 136 | } 137 | } 138 | } 139 | } -------------------------------------------------------------------------------- /WmiExplorer/Classes/ToolStripItemCollectionSorter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Windows.Forms; 4 | 5 | namespace WmiExplorer.Classes 6 | { 7 | public static class ToolStripItemExtensions 8 | { 9 | public static void SortToolStripItemCollection(this ToolStripItemCollection items) 10 | { 11 | ArrayList aList = new ArrayList(items); 12 | aList.Sort(new ToolStripItemCollectionSorter()); 13 | items.Clear(); 14 | 15 | foreach (ToolStripItem item in aList) 16 | { 17 | items.Add(item); 18 | } 19 | } 20 | } 21 | 22 | public class ToolStripItemCollectionSorter : IComparer 23 | { 24 | public int Compare(object x, object y) 25 | { 26 | // Cast the objects to be compared to ListViewItem objects 27 | ToolStripItem toolStripItemX = (ToolStripItem)x; 28 | ToolStripItem toolStripItemY = (ToolStripItem)y; 29 | 30 | return String.Compare(toolStripItemX.Text, toolStripItemY.Text, StringComparison.OrdinalIgnoreCase); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /WmiExplorer/Classes/Utilities.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Specialized; 3 | using System.Configuration; 4 | using System.Diagnostics; 5 | using System.Linq; 6 | using System.Runtime.InteropServices; 7 | using System.Security; 8 | using System.Security.Principal; 9 | using System.Windows.Forms; 10 | using WmiExplorer.Properties; 11 | 12 | namespace WmiExplorer.Classes 13 | { 14 | public static class Utilities 15 | { 16 | /// 17 | /// Checks if Application is running as Administrator 18 | /// 19 | /// True if running as Administrator. 20 | public static bool CheckIfElevated() 21 | { 22 | try 23 | { 24 | WindowsIdentity userIdentity = WindowsIdentity.GetCurrent(); 25 | WindowsPrincipal userPrincipal = new WindowsPrincipal(userIdentity); 26 | 27 | if (userPrincipal.IsInRole(WindowsBuiltInRole.Administrator)) 28 | return true; 29 | 30 | return false; 31 | } 32 | catch (Exception ex) 33 | { 34 | MessageBox.Show("Failed to determine if Application is running as Administrator: " + ex.Message); 35 | //Log("Unable to determine whether Application is running Elevated. Error: " + ex.Message); 36 | return false; 37 | } 38 | } 39 | 40 | /// 41 | /// To search and highlight text in Rich Text Box 42 | /// http://www.dotnetcurry.com/showarticle.aspx?ID=146 43 | /// 44 | /// Text to Search in RichTextBox rtb 45 | /// Start index for search 46 | /// Index of Last Search result 47 | /// RichTextBox to search in 48 | /// 49 | public static int FindTextInRichTextBox(string txtToSearch, int searchStart, int indexOfSearchText, RichTextBox rtb) 50 | { 51 | // Set the return value to -1 by default. 52 | int retVal = -1; 53 | int searchEnd = rtb.Text.Length; 54 | 55 | // A valid starting index should be specified. 56 | // if _indexOfSearchText = -1, the end of search 57 | if (searchStart >= 0 && indexOfSearchText >= 0) 58 | { 59 | // A valid ending index 60 | if (searchEnd > searchStart || searchEnd == -1) 61 | { 62 | // Find the position of search string in RichTextBox 63 | indexOfSearchText = rtb.Find(txtToSearch, searchStart, searchEnd, RichTextBoxFinds.None); 64 | 65 | // Determine whether the text was found in rtb. 66 | if (indexOfSearchText != -1) 67 | { 68 | // Return the index to the specified search text. 69 | retVal = indexOfSearchText; 70 | } 71 | } 72 | } 73 | return retVal; 74 | } 75 | 76 | /// 77 | /// Returns all Application settings 78 | /// 79 | /// String value containing name & value of all settings 80 | public static string GetSettings() 81 | { 82 | string settings = String.Empty; 83 | 84 | foreach (SettingsProperty p in from SettingsProperty p in Settings.Default.Properties 85 | orderby p.Name 86 | select p) 87 | { 88 | // Exclude UpdateCheckUrl and WindowPlacement settings 89 | if (p.Name.StartsWith("UpdateCheckUrl", StringComparison.InvariantCultureIgnoreCase) || p.Name.Equals("WindowPlacement", StringComparison.InvariantCultureIgnoreCase)) 90 | continue; 91 | 92 | // Settings containing a string array 93 | if (Settings.Default[p.Name] is StringCollection) 94 | { 95 | settings += p.Name + " = "; 96 | foreach (var s in Settings.Default[p.Name] as StringCollection) 97 | settings += s + ", "; 98 | settings += "\r\n"; 99 | continue; 100 | } 101 | 102 | // Settings without default values 103 | if (p.DefaultValue == null) 104 | { 105 | settings += p.Name + " = " + Settings.Default[p.Name] + "\r\n"; 106 | continue; 107 | } 108 | 109 | // Other settings with indicator whether value is the default value 110 | if (p.DefaultValue.ToString() == Settings.Default[p.Name].ToString()) 111 | settings += p.Name + " = " + Settings.Default[p.Name] + " (Default)\r\n"; 112 | else 113 | settings += p.Name + " = " + Settings.Default[p.Name] + "\r\n"; 114 | } 115 | 116 | return settings; 117 | } 118 | 119 | /// 120 | /// Launch the specified program 121 | /// 122 | /// Command to run 123 | public static void LaunchProgram(string sCmd) 124 | { 125 | try 126 | { 127 | Process.Start(sCmd); 128 | } 129 | catch (Exception ex) 130 | { 131 | MessageBox.Show(ex.Message, "Error launching program", MessageBoxButtons.OK, MessageBoxIcon.Error); 132 | } 133 | } 134 | 135 | /// 136 | /// Launch the specified program with arguments 137 | /// 138 | /// Command to run 139 | /// Argument for the command 140 | /// Wait for the command to Exit 141 | public static void LaunchProgram(string sCmd, string sArgument, bool bWaitForExit) 142 | { 143 | try 144 | { 145 | if (bWaitForExit) 146 | Process.Start(sCmd, sArgument).WaitForExit(); 147 | else 148 | Process.Start(sCmd, sArgument); 149 | } 150 | catch (Exception ex) 151 | { 152 | MessageBox.Show(ex.Message, "Error launching program", MessageBoxButtons.OK, MessageBoxIcon.Error); 153 | } 154 | } 155 | 156 | /// 157 | /// Returns a string from the source SecureString 158 | /// http://blogs.msdn.com/b/fpintos/archive/2009/06/12/how-to-properly-convert-securestring-to-string.aspx 159 | /// 160 | /// SecureString to convert to String 161 | /// String 162 | public static string SecureStringToString(this SecureString secureString) 163 | { 164 | if (secureString == null) 165 | throw new ArgumentNullException("secureString"); 166 | 167 | IntPtr unmanagedString = IntPtr.Zero; 168 | try 169 | { 170 | unmanagedString = Marshal.SecureStringToGlobalAllocUnicode(secureString); 171 | return Marshal.PtrToStringUni(unmanagedString); 172 | } 173 | finally 174 | { 175 | Marshal.ZeroFreeGlobalAllocUnicode(unmanagedString); 176 | } 177 | } 178 | 179 | /// 180 | /// Returns a Secure string from the source string 181 | /// http://msdn.microsoft.com/en-us/library/system.security.securestring(v=vs.110).aspx 182 | /// 183 | /// String to convert to SecureString 184 | /// SecureString 185 | public static SecureString StringToSecureString(this string source) 186 | { 187 | if (String.IsNullOrWhiteSpace(source)) 188 | return null; 189 | 190 | SecureString result = new SecureString(); 191 | foreach (char c in source.ToCharArray()) 192 | result.AppendChar(c); 193 | 194 | return result; 195 | } 196 | 197 | /// 198 | /// Update User Settings on Application version update 199 | /// http://www.ngpixel.com/2011/05/05/c-keep-user-settings-between-versions/ 200 | /// 201 | public static void UpdateSettings() 202 | { 203 | try 204 | { 205 | Settings.Default.Upgrade(); 206 | Settings.Default.bUpgradeSettings = false; 207 | Settings.Default.bUpdateAvailable = false; 208 | Settings.Default.Save(); 209 | } 210 | catch (Exception ex) 211 | { 212 | MessageBox.Show("Failed to upgrade user settings. Error: " + ex.Message); 213 | } 214 | } 215 | } 216 | } -------------------------------------------------------------------------------- /WmiExplorer/Classes/WindowPlacement.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Runtime.InteropServices; 4 | using System.Text; 5 | using System.Xml; 6 | using System.Xml.Serialization; 7 | 8 | namespace WmiExplorer.Classes 9 | { 10 | // Reference Link: David Rickard's Blog 11 | // http://blogs.msdn.com/b/davidrickard/archive/2010/03/09/saving-window-size-and-location-in-wpf-and-winforms.aspx 12 | 13 | // POINT structure required by WINDOWPLACEMENT structure 14 | [Serializable] 15 | [StructLayout(LayoutKind.Sequential)] 16 | public struct POINT 17 | { 18 | public int X; 19 | public int Y; 20 | 21 | public POINT(int x, int y) 22 | { 23 | X = x; 24 | Y = y; 25 | } 26 | } 27 | 28 | // RECT structure required by WINDOWPLACEMENT structure 29 | [Serializable] 30 | [StructLayout(LayoutKind.Sequential)] 31 | public struct RECT 32 | { 33 | public int Left; 34 | public int Top; 35 | public int Right; 36 | public int Bottom; 37 | 38 | public RECT(int left, int top, int right, int bottom) 39 | { 40 | Left = left; 41 | Top = top; 42 | Right = right; 43 | Bottom = bottom; 44 | } 45 | } 46 | 47 | // WINDOWPLACEMENT stores the position, size, and state of a window 48 | [Serializable] 49 | [StructLayout(LayoutKind.Sequential)] 50 | public struct WINDOWPLACEMENT 51 | { 52 | public int length; 53 | public int flags; 54 | public int showCmd; 55 | public POINT minPosition; 56 | public POINT maxPosition; 57 | public RECT normalPosition; 58 | } 59 | 60 | internal class WindowPlacement 61 | { 62 | private const int SW_SHOWMINIMIZED = 2; 63 | private const int SW_SHOWNORMAL = 1; 64 | private static readonly Encoding Encoding = new ASCIIEncoding(); 65 | private static readonly XmlSerializer Serializer = new XmlSerializer(typeof(WINDOWPLACEMENT)); 66 | 67 | public static string GetPlacement(IntPtr windowHandle) 68 | { 69 | WINDOWPLACEMENT placement; 70 | NativeMethods.GetWindowPlacement(windowHandle, out placement); 71 | 72 | using (MemoryStream memoryStream = new MemoryStream()) 73 | { 74 | using (XmlTextWriter xmlTextWriter = new XmlTextWriter(memoryStream, Encoding.ASCII)) 75 | { 76 | Serializer.Serialize(xmlTextWriter, placement); 77 | byte[] xmlBytes = memoryStream.ToArray(); 78 | return Encoding.GetString(xmlBytes); 79 | } 80 | } 81 | } 82 | 83 | public static void SetPlacement(IntPtr windowHandle, string placementXml) 84 | { 85 | if (string.IsNullOrEmpty(placementXml)) 86 | { 87 | return; 88 | } 89 | 90 | byte[] xmlBytes = Encoding.GetBytes(placementXml); 91 | 92 | try 93 | { 94 | WINDOWPLACEMENT placement; 95 | using (MemoryStream memoryStream = new MemoryStream(xmlBytes)) 96 | { 97 | placement = (WINDOWPLACEMENT)Serializer.Deserialize(memoryStream); 98 | } 99 | 100 | placement.length = Marshal.SizeOf(typeof(WINDOWPLACEMENT)); 101 | placement.flags = 0; 102 | placement.showCmd = (placement.showCmd == SW_SHOWMINIMIZED ? SW_SHOWNORMAL : placement.showCmd); 103 | NativeMethods.SetWindowPlacement(windowHandle, ref placement); 104 | } 105 | catch (InvalidOperationException) 106 | { 107 | // Parsing placement XML failed. Fail silently. 108 | } 109 | } 110 | } 111 | } -------------------------------------------------------------------------------- /WmiExplorer/Classes/WmiClass.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Management; 5 | using System.Windows.Forms; 6 | 7 | namespace WmiExplorer.Classes 8 | { 9 | internal class WmiClass 10 | { 11 | public List Instances = new List(); 12 | private string _description; 13 | private string _displayName; 14 | private string _enumerationStatus; 15 | private DateTime _enumTime; 16 | private TimeSpan _enumTimeElapsed; 17 | private bool _hasLazyProperties; 18 | private string _instanceFilterQuick; 19 | private string _namespacePath; 20 | private string _path; 21 | private string _relativePath; 22 | 23 | public WmiClass(ManagementClass actualClass) 24 | { 25 | Class = actualClass; 26 | } 27 | 28 | public ManagementClass Class { get; set; } 29 | 30 | public string Description 31 | { 32 | get 33 | { 34 | try 35 | { 36 | foreach (QualifierData q in from QualifierData q in Class.Qualifiers where q.Name.Equals("Description", StringComparison.CurrentCultureIgnoreCase) select q) 37 | { 38 | _description = Class.GetQualifierValue("Description").ToString(); 39 | } 40 | } 41 | catch (ManagementException ex) 42 | { 43 | if ((ex.ErrorCode).ToString() == "NotFound") 44 | _description = String.Empty; 45 | else 46 | _description = "Error getting Class Description"; 47 | } 48 | 49 | return _description; 50 | } 51 | } 52 | 53 | public string DisplayName 54 | { 55 | get 56 | { 57 | if (_displayName == null) 58 | _displayName = Class.ClassPath.ClassName; 59 | 60 | return _displayName; 61 | } 62 | set { _displayName = value; } 63 | } 64 | 65 | public string EnumerationStatus 66 | { 67 | get 68 | { 69 | if (String.IsNullOrEmpty(_enumerationStatus)) 70 | _enumerationStatus = "NoError"; 71 | 72 | return _enumerationStatus; 73 | } 74 | set { _enumerationStatus = value; } 75 | } 76 | 77 | public DateTime EnumTime 78 | { 79 | get { return _enumTime; } 80 | set { _enumTime = value; } 81 | } 82 | 83 | public TimeSpan EnumTimeElapsed 84 | { 85 | get { return _enumTimeElapsed; } 86 | set { _enumTimeElapsed = value; } 87 | } 88 | 89 | public bool HasLazyProperties 90 | { 91 | get 92 | { 93 | foreach (PropertyData pd in Class.Properties) 94 | { 95 | foreach (QualifierData qd in pd.Qualifiers) 96 | { 97 | if (qd.Name.Equals("lazy", StringComparison.CurrentCultureIgnoreCase)) 98 | { 99 | _hasLazyProperties = true; 100 | return _hasLazyProperties; 101 | } 102 | } 103 | } 104 | 105 | return _hasLazyProperties; 106 | } 107 | } 108 | 109 | public int InstanceCount { get; set; } 110 | 111 | public string InstanceFilterQuick 112 | { 113 | get 114 | { 115 | if (_instanceFilterQuick == null) 116 | _instanceFilterQuick = String.Empty; 117 | 118 | return _instanceFilterQuick; 119 | } 120 | set { _instanceFilterQuick = value; } 121 | } 122 | 123 | // Indicates if class has instances enumerated 124 | public bool IsEnumerated { get; set; } 125 | 126 | // Indicates if class is currently being enumerated 127 | public bool IsEnumerating { get; set; } 128 | 129 | // Indicates if cancellation is requested for this class. 130 | public bool IsEnumerationCancelled { get; set; } 131 | 132 | // Indicates if class has instances partially enumerated. This can occur if user cancels operation. 133 | public bool IsPartiallyEnumerated { get; set; } 134 | 135 | public string NamespacePath 136 | { 137 | get 138 | { 139 | if (_namespacePath == null) 140 | _namespacePath = Class.Scope.Path.Path; 141 | 142 | return _namespacePath; 143 | } 144 | } 145 | 146 | public string Path 147 | { 148 | get 149 | { 150 | if (_path == null) 151 | _path = Class.Path.Path; 152 | return _path; 153 | } 154 | } 155 | 156 | public string RelativePath 157 | { 158 | get 159 | { 160 | if (_relativePath == null) 161 | _relativePath = Class.Path.RelativePath; 162 | 163 | return _relativePath; 164 | } 165 | } 166 | 167 | public void AddInstance(ListViewItem listItemInstance) 168 | { 169 | Instances.Add(listItemInstance); 170 | } 171 | 172 | public string GetClassMof(bool bAmended = false) 173 | { 174 | Class.Options.UseAmendedQualifiers = bAmended; 175 | Class.Get(); 176 | return Class.GetText(TextFormat.Mof).Replace("\n", "\r\n"); 177 | } 178 | 179 | public void ResetInstances() 180 | { 181 | InstanceCount = Instances.Count; 182 | Instances = new List(); 183 | } 184 | } 185 | } -------------------------------------------------------------------------------- /WmiExplorer/Classes/WmiInstance.cs: -------------------------------------------------------------------------------- 1 | using System.Management; 2 | 3 | namespace WmiExplorer.Classes 4 | { 5 | internal class WmiInstance 6 | { 7 | private string _path; 8 | private string _relativePath; 9 | 10 | public WmiInstance(ManagementObject actualObject) 11 | { 12 | Instance = actualObject; 13 | } 14 | 15 | public ManagementObject Instance { get; set; } 16 | 17 | public string Path 18 | { 19 | get 20 | { 21 | if (_path == null) 22 | _path = Instance.Path.Path; 23 | 24 | return _path; 25 | } 26 | } 27 | 28 | public string RelativePath 29 | { 30 | get 31 | { 32 | if (_relativePath == null) 33 | _relativePath = Instance.Path.RelativePath; 34 | 35 | return _relativePath; 36 | } 37 | } 38 | 39 | public string GetInstanceMof(bool bAmended = false) 40 | { 41 | if (bAmended) 42 | Instance.Options.UseAmendedQualifiers = true; 43 | else 44 | Instance.Options.UseAmendedQualifiers = false; 45 | 46 | Instance.Get(); 47 | return Instance.GetText(TextFormat.Mof).Replace("\n", "\r\n"); 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /WmiExplorer/Classes/WmiMethod.cs: -------------------------------------------------------------------------------- 1 | using System.Management; 2 | 3 | namespace WmiExplorer.Classes 4 | { 5 | internal class WmiMethod 6 | { 7 | private string _description; 8 | private bool _isStatic; 9 | private string _methodName; 10 | private string _path; 11 | private MethodData _wmiMethod; 12 | 13 | public WmiMethod(MethodData actualMethod) 14 | { 15 | _wmiMethod = actualMethod; 16 | } 17 | 18 | public string Description 19 | { 20 | get { return _description; } 21 | set { _description = value; } 22 | } 23 | 24 | public bool IsStatic 25 | { 26 | get { return _isStatic; } 27 | set { _isStatic = value; } 28 | } 29 | 30 | public string MethodName 31 | { 32 | get { return _methodName; } 33 | set { _methodName = value; } 34 | } 35 | 36 | public string Path 37 | { 38 | get { return _path; } 39 | set { _path = value; } 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /WmiExplorer/Classes/WmiNamespace.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Management; 4 | using System.Windows.Forms; 5 | 6 | namespace WmiExplorer.Classes 7 | { 8 | internal class WmiNamespace 9 | { 10 | public int ClassCount = 0; 11 | public List Classes = new List(); 12 | private readonly ManagementObject _wmiNamespace; 13 | private string _classFilter; // Class Filter for current namespace 14 | private string _classFilterQuick; // Quick Filter for current namespace 15 | private string _displayName; // Display Name of the current namespace 16 | private string _enumerationStatus; // Class Enumeration status of current namespace 17 | private DateTime _enumTime; // Enumeration Time of current namespace 18 | private TimeSpan _enumTimeElapsed; // Time taken to enumerate classes for current namespace 19 | private bool _isRootNode; // Indicates if current namespace is the root node 20 | private string _path; // Path of the current namespace 21 | private string _relativePath; // Relative Path of current namespace 22 | private string _serverName; // Server name 23 | 24 | public WmiNamespace(ManagementObject actualNamespace) 25 | { 26 | _wmiNamespace = actualNamespace; 27 | } 28 | 29 | public string ClassFilter 30 | { 31 | get 32 | { 33 | if (_classFilter == null) 34 | _classFilter = "%"; 35 | 36 | return _classFilter; 37 | } 38 | set { _classFilter = value; } 39 | } 40 | 41 | public string ClassFilterQuick 42 | { 43 | get 44 | { 45 | if (_classFilterQuick == null) 46 | _classFilterQuick = String.Empty; 47 | 48 | return _classFilterQuick; 49 | } 50 | set { _classFilterQuick = value; } 51 | } 52 | 53 | public string DisplayName 54 | { 55 | get 56 | { 57 | if (_displayName == null) 58 | { 59 | if (IsRootNode) 60 | _displayName = _wmiNamespace.Scope.Path.Path.ToUpper(); 61 | else 62 | _displayName = RelativePath; 63 | } 64 | return _displayName; 65 | } 66 | set { _displayName = value; } 67 | } 68 | 69 | public string EnumerationStatus 70 | { 71 | get 72 | { 73 | if (String.IsNullOrEmpty(_enumerationStatus)) 74 | _enumerationStatus = "NoError"; 75 | 76 | return _enumerationStatus; 77 | } 78 | set { _enumerationStatus = value; } 79 | } 80 | 81 | public DateTime EnumTime 82 | { 83 | get { return _enumTime; } 84 | set { _enumTime = value; } 85 | } 86 | 87 | public TimeSpan EnumTimeElapsed 88 | { 89 | get { return _enumTimeElapsed; } 90 | set { _enumTimeElapsed = value; } 91 | } 92 | 93 | // Indicates if current namespace has classes enumerated 94 | public bool IsEnumerated { get; set; } 95 | 96 | // Indicates if current namespace is currently being enumerated 97 | public bool IsEnumerating { get; set; } 98 | 99 | // Indicates if cancellation is requested for this namespace. 100 | public bool IsEnumerationCancelled { get; set; } 101 | 102 | // Indicates if current namespace has classes partially enumerated. This can occur if user cancels operation. 103 | public bool IsPartiallyEnumerated { get; set; } 104 | 105 | public bool IsRootNode 106 | { 107 | get 108 | { 109 | // Namespace in root node has Path.Path set to Empty string 110 | if (String.IsNullOrEmpty(_wmiNamespace.Path.Path)) 111 | _isRootNode = true; 112 | else 113 | _isRootNode = false; 114 | 115 | return _isRootNode; 116 | } 117 | } 118 | 119 | public string Path 120 | { 121 | get 122 | { 123 | if (_path == null) 124 | { 125 | if (IsRootNode) 126 | _path = _wmiNamespace.Scope.Path.Path.ToUpper(); 127 | else 128 | _path = "\\\\" + _wmiNamespace.Path.Server + "\\" + _wmiNamespace.GetPropertyValue("__Namespace") + "\\" + _wmiNamespace.GetPropertyValue("Name"); 129 | } 130 | return _path; 131 | } 132 | } 133 | 134 | public string RelativePath 135 | { 136 | get 137 | { 138 | if (_relativePath == null) 139 | { 140 | if (IsRootNode) 141 | _relativePath = _wmiNamespace.Scope.Path.NamespacePath.ToUpper(); 142 | else 143 | _relativePath = _wmiNamespace.GetPropertyValue("__NAMESPACE") + "\\" + _wmiNamespace.GetPropertyValue("Name"); 144 | } 145 | return _relativePath; 146 | } 147 | } 148 | 149 | public string ServerName 150 | { 151 | get 152 | { 153 | if (_serverName == null) 154 | _serverName = _wmiNamespace.Scope.Path.Server; 155 | 156 | return _serverName; 157 | } 158 | set { _serverName = value; } 159 | } 160 | 161 | /// 162 | /// Adds new list item to _classes. Called by ObserverHandler when NewObject arrives. 163 | /// 164 | /// 165 | public void AddClass(ListViewItem listItemClass) 166 | { 167 | Classes.Add(listItemClass); 168 | } 169 | 170 | /// 171 | /// Resets contents of _classes 172 | /// 173 | public void ResetClasses() 174 | { 175 | ClassCount = Classes.Count; 176 | Classes = new List(); 177 | } 178 | } 179 | } -------------------------------------------------------------------------------- /WmiExplorer/Classes/WmiNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Management; 3 | using WmiExplorer.Sms; 4 | 5 | namespace WmiExplorer.Classes 6 | { 7 | internal class WmiNode 8 | { 9 | private ConnectionOptions _connection; 10 | 11 | private string _expansionStatus; 12 | 13 | private string _userSpecifiedPath; 14 | 15 | // Constructor to create Root Node 16 | public WmiNode() 17 | { 18 | } 19 | 20 | // Constructor to create Wmi Node for the specified namespace 21 | public WmiNode(ManagementObject wmiNamespace) 22 | { 23 | WmiNamespace = new WmiNamespace(wmiNamespace); 24 | //_connection = wmiNamespace.Scope.Options; 25 | } 26 | 27 | public ConnectionOptions Connection 28 | { 29 | get { return _connection; } 30 | } 31 | 32 | public string ExpansionStatus 33 | { 34 | get 35 | { 36 | if (String.IsNullOrEmpty(_expansionStatus)) 37 | _expansionStatus = "NoError"; 38 | 39 | return _expansionStatus; 40 | } 41 | set { _expansionStatus = value; } 42 | } 43 | 44 | public bool IsConnected { get; set; } 45 | 46 | public bool IsExpanded { get; set; } 47 | 48 | public bool IsRootNode { get; set; } 49 | 50 | public SmsClient SmsClient { get; set; } 51 | 52 | public string UserSpecifiedPath 53 | { 54 | get { return _userSpecifiedPath; } 55 | set 56 | { 57 | _userSpecifiedPath = IsRootNode ? value : "NotApplicable"; 58 | } 59 | } 60 | 61 | public WmiNamespace WmiNamespace { get; set; } 62 | 63 | public void SetConnection(ConnectionOptions value) 64 | { 65 | _connection = value; 66 | } 67 | } 68 | } -------------------------------------------------------------------------------- /WmiExplorer/Forms/Form_About.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace WmiExplorer.Forms 2 | { 3 | partial class Form_About 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | protected override void Dispose(bool disposing) 14 | { 15 | if (disposing && (components != null)) 16 | { 17 | components.Dispose(); 18 | } 19 | base.Dispose(disposing); 20 | } 21 | 22 | #region Windows Form Designer generated code 23 | 24 | /// 25 | /// Required method for Designer support - do not modify 26 | /// the contents of this method with the code editor. 27 | /// 28 | private void InitializeComponent() 29 | { 30 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form_About)); 31 | this.tableLayoutPanel = new System.Windows.Forms.TableLayoutPanel(); 32 | this.logoPictureBox = new System.Windows.Forms.PictureBox(); 33 | this.labelProductName = new System.Windows.Forms.Label(); 34 | this.labelVersion = new System.Windows.Forms.Label(); 35 | this.labelCopyright = new System.Windows.Forms.Label(); 36 | this.okButton = new System.Windows.Forms.Button(); 37 | this.textBoxDescription = new System.Windows.Forms.TextBox(); 38 | this.tableLayoutPanel.SuspendLayout(); 39 | ((System.ComponentModel.ISupportInitialize)(this.logoPictureBox)).BeginInit(); 40 | this.SuspendLayout(); 41 | // 42 | // tableLayoutPanel 43 | // 44 | this.tableLayoutPanel.ColumnCount = 2; 45 | this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33F)); 46 | this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 67F)); 47 | this.tableLayoutPanel.Controls.Add(this.logoPictureBox, 0, 0); 48 | this.tableLayoutPanel.Controls.Add(this.labelProductName, 1, 0); 49 | this.tableLayoutPanel.Controls.Add(this.labelVersion, 1, 1); 50 | this.tableLayoutPanel.Controls.Add(this.labelCopyright, 1, 2); 51 | this.tableLayoutPanel.Controls.Add(this.okButton, 1, 5); 52 | this.tableLayoutPanel.Controls.Add(this.textBoxDescription, 1, 4); 53 | this.tableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill; 54 | this.tableLayoutPanel.Location = new System.Drawing.Point(9, 9); 55 | this.tableLayoutPanel.Name = "tableLayoutPanel"; 56 | this.tableLayoutPanel.RowCount = 6; 57 | this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); 58 | this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); 59 | this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); 60 | this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 4F)); 61 | this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 56F)); 62 | this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F)); 63 | this.tableLayoutPanel.Size = new System.Drawing.Size(416, 263); 64 | this.tableLayoutPanel.TabIndex = 0; 65 | // 66 | // logoPictureBox 67 | // 68 | this.logoPictureBox.Dock = System.Windows.Forms.DockStyle.Fill; 69 | this.logoPictureBox.Image = ((System.Drawing.Image)(resources.GetObject("logoPictureBox.Image"))); 70 | this.logoPictureBox.Location = new System.Drawing.Point(3, 3); 71 | this.logoPictureBox.Name = "logoPictureBox"; 72 | this.tableLayoutPanel.SetRowSpan(this.logoPictureBox, 6); 73 | this.logoPictureBox.Size = new System.Drawing.Size(131, 257); 74 | this.logoPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; 75 | this.logoPictureBox.TabIndex = 12; 76 | this.logoPictureBox.TabStop = false; 77 | // 78 | // labelProductName 79 | // 80 | this.labelProductName.Dock = System.Windows.Forms.DockStyle.Fill; 81 | this.labelProductName.Location = new System.Drawing.Point(143, 0); 82 | this.labelProductName.Margin = new System.Windows.Forms.Padding(6, 0, 3, 0); 83 | this.labelProductName.MaximumSize = new System.Drawing.Size(0, 17); 84 | this.labelProductName.Name = "labelProductName"; 85 | this.labelProductName.Size = new System.Drawing.Size(270, 17); 86 | this.labelProductName.TabIndex = 19; 87 | this.labelProductName.Text = "Product Name"; 88 | this.labelProductName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; 89 | // 90 | // labelVersion 91 | // 92 | this.labelVersion.Dock = System.Windows.Forms.DockStyle.Fill; 93 | this.labelVersion.Location = new System.Drawing.Point(143, 26); 94 | this.labelVersion.Margin = new System.Windows.Forms.Padding(6, 0, 3, 0); 95 | this.labelVersion.MaximumSize = new System.Drawing.Size(0, 17); 96 | this.labelVersion.Name = "labelVersion"; 97 | this.labelVersion.Size = new System.Drawing.Size(270, 17); 98 | this.labelVersion.TabIndex = 0; 99 | this.labelVersion.Text = "Version"; 100 | this.labelVersion.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; 101 | // 102 | // labelCopyright 103 | // 104 | this.labelCopyright.Dock = System.Windows.Forms.DockStyle.Fill; 105 | this.labelCopyright.Location = new System.Drawing.Point(143, 52); 106 | this.labelCopyright.Margin = new System.Windows.Forms.Padding(6, 0, 3, 0); 107 | this.labelCopyright.MaximumSize = new System.Drawing.Size(0, 17); 108 | this.labelCopyright.Name = "labelCopyright"; 109 | this.labelCopyright.Size = new System.Drawing.Size(270, 17); 110 | this.labelCopyright.TabIndex = 21; 111 | this.labelCopyright.Text = "Copyright"; 112 | this.labelCopyright.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; 113 | // 114 | // okButton 115 | // 116 | this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 117 | this.okButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; 118 | this.okButton.Location = new System.Drawing.Point(338, 238); 119 | this.okButton.Name = "okButton"; 120 | this.okButton.Size = new System.Drawing.Size(75, 22); 121 | this.okButton.TabIndex = 24; 122 | this.okButton.Text = "&OK"; 123 | // 124 | // textBoxDescription 125 | // 126 | this.textBoxDescription.BorderStyle = System.Windows.Forms.BorderStyle.None; 127 | this.textBoxDescription.Dock = System.Windows.Forms.DockStyle.Fill; 128 | this.textBoxDescription.Location = new System.Drawing.Point(143, 91); 129 | this.textBoxDescription.Margin = new System.Windows.Forms.Padding(6, 3, 3, 3); 130 | this.textBoxDescription.Multiline = true; 131 | this.textBoxDescription.Name = "textBoxDescription"; 132 | this.textBoxDescription.ReadOnly = true; 133 | this.textBoxDescription.Size = new System.Drawing.Size(270, 141); 134 | this.textBoxDescription.TabIndex = 23; 135 | this.textBoxDescription.TabStop = false; 136 | this.textBoxDescription.Text = resources.GetString("textBoxDescription.Text"); 137 | // 138 | // Form_About 139 | // 140 | this.AcceptButton = this.okButton; 141 | this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); 142 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; 143 | this.AutoSize = true; 144 | this.CancelButton = this.okButton; 145 | this.ClientSize = new System.Drawing.Size(434, 281); 146 | this.Controls.Add(this.tableLayoutPanel); 147 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; 148 | this.MaximizeBox = false; 149 | this.MinimizeBox = false; 150 | this.Name = "Form_About"; 151 | this.Padding = new System.Windows.Forms.Padding(9); 152 | this.ShowIcon = false; 153 | this.ShowInTaskbar = false; 154 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; 155 | this.Text = "Form_About"; 156 | this.tableLayoutPanel.ResumeLayout(false); 157 | this.tableLayoutPanel.PerformLayout(); 158 | ((System.ComponentModel.ISupportInitialize)(this.logoPictureBox)).EndInit(); 159 | this.ResumeLayout(false); 160 | 161 | } 162 | 163 | #endregion 164 | 165 | private System.Windows.Forms.TableLayoutPanel tableLayoutPanel; 166 | private System.Windows.Forms.PictureBox logoPictureBox; 167 | private System.Windows.Forms.Label labelProductName; 168 | private System.Windows.Forms.Label labelVersion; 169 | private System.Windows.Forms.Label labelCopyright; 170 | private System.Windows.Forms.TextBox textBoxDescription; 171 | private System.Windows.Forms.Button okButton; 172 | } 173 | } 174 | -------------------------------------------------------------------------------- /WmiExplorer/Forms/Form_About.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Windows.Forms; 4 | 5 | namespace WmiExplorer.Forms 6 | { 7 | partial class Form_About : Form 8 | { 9 | public Form_About() 10 | { 11 | InitializeComponent(); 12 | this.Text = String.Format("About {0}", AssemblyTitle); 13 | this.labelProductName.Text = AssemblyProduct; 14 | this.labelVersion.Text = String.Format("Version {0}", AssemblyVersion); 15 | this.labelCopyright.Text = AssemblyCopyright; 16 | //this.labelCompanyName.Text = AssemblyCompany; 17 | //this.textBoxDescription.Text = AssemblyDescription; 18 | } 19 | 20 | #region Assembly Attribute Accessors 21 | 22 | public string AssemblyTitle 23 | { 24 | get 25 | { 26 | object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false); 27 | if (attributes.Length > 0) 28 | { 29 | AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0]; 30 | if (titleAttribute.Title != "") 31 | { 32 | return titleAttribute.Title; 33 | } 34 | } 35 | return System.IO.Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase); 36 | } 37 | } 38 | 39 | public string AssemblyVersion 40 | { 41 | get 42 | { 43 | return Assembly.GetExecutingAssembly().GetName().Version.ToString(); 44 | } 45 | } 46 | 47 | public string AssemblyDescription 48 | { 49 | get 50 | { 51 | object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false); 52 | if (attributes.Length == 0) 53 | { 54 | return ""; 55 | } 56 | return ((AssemblyDescriptionAttribute)attributes[0]).Description; 57 | } 58 | } 59 | 60 | public string AssemblyProduct 61 | { 62 | get 63 | { 64 | object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), false); 65 | if (attributes.Length == 0) 66 | { 67 | return ""; 68 | } 69 | return ((AssemblyProductAttribute)attributes[0]).Product; 70 | } 71 | } 72 | 73 | public string AssemblyCopyright 74 | { 75 | get 76 | { 77 | object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false); 78 | if (attributes.Length == 0) 79 | { 80 | return ""; 81 | } 82 | return ((AssemblyCopyrightAttribute)attributes[0]).Copyright; 83 | } 84 | } 85 | 86 | public string AssemblyCompany 87 | { 88 | get 89 | { 90 | object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), false); 91 | if (attributes.Length == 0) 92 | { 93 | return ""; 94 | } 95 | return ((AssemblyCompanyAttribute)attributes[0]).Company; 96 | } 97 | } 98 | #endregion 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /WmiExplorer/Forms/Form_ConnectAs.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace WmiExplorer.Forms 2 | { 3 | partial class Form_ConnectAs 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.buttonCancel = new System.Windows.Forms.Button(); 32 | this.buttonConnect = new System.Windows.Forms.Button(); 33 | this.labelPassword = new System.Windows.Forms.Label(); 34 | this.textBoxPassword = new System.Windows.Forms.TextBox(); 35 | this.labelUsername = new System.Windows.Forms.Label(); 36 | this.textBoxUsername = new System.Windows.Forms.TextBox(); 37 | this.labelPath = new System.Windows.Forms.Label(); 38 | this.textBoxPath = new System.Windows.Forms.TextBox(); 39 | this.labelDescription = new System.Windows.Forms.Label(); 40 | this.SuspendLayout(); 41 | // 42 | // buttonCancel 43 | // 44 | this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; 45 | this.buttonCancel.Location = new System.Drawing.Point(15, 178); 46 | this.buttonCancel.Margin = new System.Windows.Forms.Padding(10); 47 | this.buttonCancel.Name = "buttonCancel"; 48 | this.buttonCancel.Size = new System.Drawing.Size(108, 23); 49 | this.buttonCancel.TabIndex = 4; 50 | this.buttonCancel.Text = "Cancel"; 51 | this.buttonCancel.UseVisualStyleBackColor = true; 52 | this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); 53 | // 54 | // buttonConnect 55 | // 56 | this.buttonConnect.Location = new System.Drawing.Point(259, 178); 57 | this.buttonConnect.Margin = new System.Windows.Forms.Padding(10); 58 | this.buttonConnect.Name = "buttonConnect"; 59 | this.buttonConnect.Size = new System.Drawing.Size(113, 23); 60 | this.buttonConnect.TabIndex = 3; 61 | this.buttonConnect.Text = "Connect"; 62 | this.buttonConnect.UseVisualStyleBackColor = true; 63 | this.buttonConnect.Click += new System.EventHandler(this.buttonOk_Click); 64 | // 65 | // labelPassword 66 | // 67 | this.labelPassword.AutoSize = true; 68 | this.labelPassword.Location = new System.Drawing.Point(12, 129); 69 | this.labelPassword.Name = "labelPassword"; 70 | this.labelPassword.Size = new System.Drawing.Size(56, 13); 71 | this.labelPassword.TabIndex = 18; 72 | this.labelPassword.Text = "Password:"; 73 | // 74 | // textBoxPassword 75 | // 76 | this.textBoxPassword.Location = new System.Drawing.Point(15, 146); 77 | this.textBoxPassword.Name = "textBoxPassword"; 78 | this.textBoxPassword.Size = new System.Drawing.Size(357, 20); 79 | this.textBoxPassword.TabIndex = 2; 80 | this.textBoxPassword.UseSystemPasswordChar = true; 81 | // 82 | // labelUsername 83 | // 84 | this.labelUsername.AutoSize = true; 85 | this.labelUsername.Location = new System.Drawing.Point(12, 86); 86 | this.labelUsername.Name = "labelUsername"; 87 | this.labelUsername.Size = new System.Drawing.Size(169, 13); 88 | this.labelUsername.TabIndex = 16; 89 | this.labelUsername.Text = "Username (DOMAIN\\User format):"; 90 | // 91 | // textBoxUsername 92 | // 93 | this.textBoxUsername.Location = new System.Drawing.Point(15, 103); 94 | this.textBoxUsername.Name = "textBoxUsername"; 95 | this.textBoxUsername.Size = new System.Drawing.Size(357, 20); 96 | this.textBoxUsername.TabIndex = 1; 97 | // 98 | // labelPath 99 | // 100 | this.labelPath.AutoSize = true; 101 | this.labelPath.Location = new System.Drawing.Point(12, 43); 102 | this.labelPath.Name = "labelPath"; 103 | this.labelPath.Size = new System.Drawing.Size(122, 13); 104 | this.labelPath.TabIndex = 14; 105 | this.labelPath.Text = "Remote Computer/Path:"; 106 | // 107 | // textBoxPath 108 | // 109 | this.textBoxPath.Location = new System.Drawing.Point(15, 60); 110 | this.textBoxPath.Name = "textBoxPath"; 111 | this.textBoxPath.Size = new System.Drawing.Size(357, 20); 112 | this.textBoxPath.TabIndex = 0; 113 | // 114 | // labelDescription 115 | // 116 | this.labelDescription.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 117 | | System.Windows.Forms.AnchorStyles.Right))); 118 | this.labelDescription.Location = new System.Drawing.Point(12, 9); 119 | this.labelDescription.Name = "labelDescription"; 120 | this.labelDescription.Size = new System.Drawing.Size(360, 36); 121 | this.labelDescription.TabIndex = 5; 122 | this.labelDescription.Text = "Connect to a remote computer/path using Alternate Credentials. Alternate Credenti" + 123 | "als can only be used for remote connections."; 124 | // 125 | // Form_ConnectAs 126 | // 127 | this.AcceptButton = this.buttonConnect; 128 | this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); 129 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; 130 | this.AutoSize = true; 131 | this.CancelButton = this.buttonCancel; 132 | this.ClientSize = new System.Drawing.Size(384, 211); 133 | this.ControlBox = false; 134 | this.Controls.Add(this.buttonConnect); 135 | this.Controls.Add(this.buttonCancel); 136 | this.Controls.Add(this.textBoxPassword); 137 | this.Controls.Add(this.labelPassword); 138 | this.Controls.Add(this.textBoxUsername); 139 | this.Controls.Add(this.labelUsername); 140 | this.Controls.Add(this.textBoxPath); 141 | this.Controls.Add(this.labelPath); 142 | this.Controls.Add(this.labelDescription); 143 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; 144 | this.MinimizeBox = false; 145 | this.Name = "Form_ConnectAs"; 146 | this.ShowIcon = false; 147 | this.ShowInTaskbar = false; 148 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; 149 | this.Text = "Connect As..."; 150 | this.ResumeLayout(false); 151 | this.PerformLayout(); 152 | 153 | } 154 | 155 | #endregion 156 | 157 | private System.Windows.Forms.Button buttonCancel; 158 | private System.Windows.Forms.Button buttonConnect; 159 | private System.Windows.Forms.Label labelPassword; 160 | private System.Windows.Forms.TextBox textBoxPassword; 161 | private System.Windows.Forms.Label labelUsername; 162 | private System.Windows.Forms.TextBox textBoxUsername; 163 | private System.Windows.Forms.Label labelPath; 164 | private System.Windows.Forms.TextBox textBoxPath; 165 | private System.Windows.Forms.Label labelDescription; 166 | 167 | 168 | } 169 | } -------------------------------------------------------------------------------- /WmiExplorer/Forms/Form_ConnectAs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Management; 3 | using System.Windows.Forms; 4 | using WmiExplorer.Classes; 5 | 6 | namespace WmiExplorer.Forms 7 | { 8 | public partial class Form_ConnectAs : Form 9 | { 10 | public ConnectionOptions Connection; 11 | public string Path; 12 | public bool Cancelled; 13 | 14 | public Form_ConnectAs(string path = "") 15 | { 16 | InitializeComponent(); 17 | 18 | if (!String.IsNullOrEmpty(path)) 19 | { 20 | textBoxPath.Text = path; 21 | textBoxPath.ReadOnly = true; 22 | textBoxUsername.Select(); 23 | } 24 | 25 | } 26 | 27 | private void buttonOk_Click(object sender, EventArgs e) 28 | { 29 | if (String.IsNullOrEmpty(textBoxPath.Text)) 30 | { 31 | MessageBox.Show("No path specified. Please specify a remote computer/path to connect to. ", 32 | "Invalid Path", MessageBoxButtons.OK, MessageBoxIcon.Error); 33 | return; 34 | } 35 | 36 | Path = textBoxPath.Text.ToUpperInvariant(); 37 | Connection = new ConnectionOptions 38 | { 39 | EnablePrivileges = true, 40 | Impersonation = ImpersonationLevel.Impersonate, 41 | Authentication = AuthenticationLevel.Default, 42 | Username = textBoxUsername.Text, 43 | SecurePassword = textBoxPassword.Text.StringToSecureString() 44 | }; 45 | 46 | if (String.IsNullOrEmpty(textBoxUsername.Text)) 47 | { 48 | MessageBox.Show("No username specified. Logged on user's credentials will be used. ", 49 | "Invalid Credentials", MessageBoxButtons.OK, MessageBoxIcon.Warning); 50 | Connection.Username = null; 51 | Connection.SecurePassword = null; 52 | } 53 | 54 | Close(); 55 | } 56 | 57 | private void buttonCancel_Click(object sender, EventArgs e) 58 | { 59 | Cancelled = true; 60 | Close(); 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /WmiExplorer/Forms/Form_ConnectAs.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /WmiExplorer/Forms/Form_DisplayText.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace WmiExplorer.Forms 2 | { 3 | partial class Form_DisplayText 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.buttonOk = new System.Windows.Forms.Button(); 32 | this.richTextBox = new System.Windows.Forms.RichTextBox(); 33 | this.labelCaption = new System.Windows.Forms.Label(); 34 | this.SuspendLayout(); 35 | // 36 | // buttonOk 37 | // 38 | this.buttonOk.Anchor = System.Windows.Forms.AnchorStyles.Bottom; 39 | this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.Cancel; 40 | this.buttonOk.Location = new System.Drawing.Point(194, 249); 41 | this.buttonOk.Name = "buttonOk"; 42 | this.buttonOk.Size = new System.Drawing.Size(100, 25); 43 | this.buttonOk.TabIndex = 2; 44 | this.buttonOk.Text = "OK"; 45 | this.buttonOk.UseVisualStyleBackColor = true; 46 | this.buttonOk.Click += new System.EventHandler(this.buttonOk_Click); 47 | // 48 | // richTextBox 49 | // 50 | this.richTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 51 | | System.Windows.Forms.AnchorStyles.Left) 52 | | System.Windows.Forms.AnchorStyles.Right))); 53 | this.richTextBox.BorderStyle = System.Windows.Forms.BorderStyle.None; 54 | this.richTextBox.Location = new System.Drawing.Point(12, 49); 55 | this.richTextBox.Name = "richTextBox"; 56 | this.richTextBox.ReadOnly = true; 57 | this.richTextBox.Size = new System.Drawing.Size(470, 194); 58 | this.richTextBox.TabIndex = 3; 59 | this.richTextBox.Text = ""; 60 | this.richTextBox.WordWrap = false; 61 | // 62 | // labelCaption 63 | // 64 | this.labelCaption.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 65 | | System.Windows.Forms.AnchorStyles.Right))); 66 | this.labelCaption.BackColor = System.Drawing.Color.LightSteelBlue; 67 | this.labelCaption.Location = new System.Drawing.Point(0, 0); 68 | this.labelCaption.Name = "labelCaption"; 69 | this.labelCaption.Padding = new System.Windows.Forms.Padding(5); 70 | this.labelCaption.Size = new System.Drawing.Size(488, 35); 71 | this.labelCaption.TabIndex = 5; 72 | this.labelCaption.Text = "Title"; 73 | this.labelCaption.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; 74 | // 75 | // Form_DisplayText 76 | // 77 | this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); 78 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; 79 | this.CancelButton = this.buttonOk; 80 | this.ClientSize = new System.Drawing.Size(484, 286); 81 | this.Controls.Add(this.labelCaption); 82 | this.Controls.Add(this.richTextBox); 83 | this.Controls.Add(this.buttonOk); 84 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow; 85 | this.Name = "Form_DisplayText"; 86 | this.ShowIcon = false; 87 | this.ShowInTaskbar = false; 88 | this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show; 89 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; 90 | this.Text = "Form_DisplayText"; 91 | this.ResumeLayout(false); 92 | 93 | } 94 | 95 | #endregion 96 | 97 | private System.Windows.Forms.Button buttonOk; 98 | private System.Windows.Forms.RichTextBox richTextBox; 99 | private System.Windows.Forms.Label labelCaption; 100 | } 101 | } -------------------------------------------------------------------------------- /WmiExplorer/Forms/Form_DisplayText.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Windows.Forms; 9 | 10 | namespace WmiExplorer.Forms 11 | { 12 | public partial class Form_DisplayText : Form 13 | { 14 | public Form_DisplayText(string windowTitle, string caption, string text) 15 | { 16 | InitializeComponent(); 17 | labelCaption.Font = new Font("Arial", 10, FontStyle.Bold); 18 | Text = windowTitle; 19 | labelCaption.Text = caption; 20 | richTextBox.Text = text; 21 | } 22 | 23 | private void buttonOk_Click(object sender, EventArgs e) 24 | { 25 | this.Close(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /WmiExplorer/Forms/Form_DisplayText.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /WmiExplorer/Forms/Form_ExecMethod.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 17, 17 122 | 123 | -------------------------------------------------------------------------------- /WmiExplorer/Forms/Form_Settings.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Globalization; 4 | using System.Windows.Forms; 5 | using WmiExplorer.Properties; 6 | 7 | namespace WmiExplorer.Forms 8 | { 9 | public partial class Form_Settings : Form 10 | { 11 | private readonly string _currentCacheAge; 12 | 13 | public Form_Settings() 14 | { 15 | InitializeComponent(); 16 | _currentCacheAge = textBoxSettings_CacheAge.Text; 17 | } 18 | 19 | private void buttonSettings_Save_Click(object sender, EventArgs e) 20 | { 21 | bool restartRequired = false; 22 | 23 | if (Settings.Default.CacheAgeInMinutes != _currentCacheAge) 24 | { 25 | if (MessageBox.Show( 26 | "New Cache Age will take effect after restarting WMI Explorer.\n\n" + 27 | "Would you like to restart WMI Explorer now ?", 28 | "WMI Explorer - Restart Required", 29 | MessageBoxButtons.YesNo, 30 | MessageBoxIcon.Question 31 | ) == DialogResult.Yes) 32 | { 33 | restartRequired = true; 34 | } 35 | } 36 | 37 | Settings.Default.Save(); 38 | 39 | if (restartRequired) 40 | { 41 | Process.Start(Application.ExecutablePath); 42 | Application.Exit(); 43 | } 44 | 45 | Close(); 46 | } 47 | 48 | private void buttonSettings_Cancel_Click(object sender, EventArgs e) 49 | { 50 | Close(); 51 | } 52 | 53 | private void Form_Settings_Load(object sender, EventArgs e) 54 | { 55 | labelUpdate_LastUpdateCheck.Text += Settings.Default.LastUpdateCheck.ToString(CultureInfo.InvariantCulture); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /WmiExplorer/Forms/Form_Settings.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /WmiExplorer/Forms/Form_ShowMof.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace WmiExplorer 2 | { 3 | sealed partial class Form_ShowMof 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.textBoxShowMOF = new System.Windows.Forms.TextBox(); 32 | this.buttonCloseMof = new System.Windows.Forms.Button(); 33 | this.SuspendLayout(); 34 | // 35 | // textBoxShowMOF 36 | // 37 | this.textBoxShowMOF.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 38 | | System.Windows.Forms.AnchorStyles.Left) 39 | | System.Windows.Forms.AnchorStyles.Right))); 40 | this.textBoxShowMOF.BackColor = System.Drawing.SystemColors.Control; 41 | this.textBoxShowMOF.ImeMode = System.Windows.Forms.ImeMode.Off; 42 | this.textBoxShowMOF.Location = new System.Drawing.Point(12, 13); 43 | this.textBoxShowMOF.Multiline = true; 44 | this.textBoxShowMOF.Name = "textBoxShowMOF"; 45 | this.textBoxShowMOF.ReadOnly = true; 46 | this.textBoxShowMOF.ScrollBars = System.Windows.Forms.ScrollBars.Both; 47 | this.textBoxShowMOF.Size = new System.Drawing.Size(510, 253); 48 | this.textBoxShowMOF.TabIndex = 0; 49 | this.textBoxShowMOF.TabStop = false; 50 | this.textBoxShowMOF.WordWrap = false; 51 | // 52 | // buttonCloseMof 53 | // 54 | this.buttonCloseMof.Anchor = System.Windows.Forms.AnchorStyles.Bottom; 55 | this.buttonCloseMof.DialogResult = System.Windows.Forms.DialogResult.Cancel; 56 | this.buttonCloseMof.Location = new System.Drawing.Point(227, 274); 57 | this.buttonCloseMof.Name = "buttonCloseMof"; 58 | this.buttonCloseMof.Size = new System.Drawing.Size(75, 25); 59 | this.buttonCloseMof.TabIndex = 1; 60 | this.buttonCloseMof.Text = "Close"; 61 | this.buttonCloseMof.UseVisualStyleBackColor = true; 62 | this.buttonCloseMof.Click += new System.EventHandler(this.buttonCloseMOF_Click); 63 | // 64 | // Form_ShowMof 65 | // 66 | this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); 67 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; 68 | this.BackColor = System.Drawing.SystemColors.Control; 69 | this.CancelButton = this.buttonCloseMof; 70 | this.ClientSize = new System.Drawing.Size(534, 311); 71 | this.Controls.Add(this.buttonCloseMof); 72 | this.Controls.Add(this.textBoxShowMOF); 73 | this.Name = "Form_ShowMof"; 74 | this.ShowIcon = false; 75 | this.ShowInTaskbar = false; 76 | this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show; 77 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; 78 | this.Text = "MOF"; 79 | this.ResumeLayout(false); 80 | this.PerformLayout(); 81 | 82 | } 83 | 84 | #endregion 85 | 86 | private System.Windows.Forms.TextBox textBoxShowMOF; 87 | private System.Windows.Forms.Button buttonCloseMof; 88 | } 89 | } -------------------------------------------------------------------------------- /WmiExplorer/Forms/Form_ShowMof.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Windows.Forms; 9 | 10 | namespace WmiExplorer 11 | { 12 | 13 | public sealed partial class Form_ShowMof : Form 14 | { 15 | public Form_ShowMof(string mofText) 16 | { 17 | InitializeComponent(); 18 | textBoxShowMOF.Text = "\r\n" + mofText; 19 | } 20 | 21 | private void buttonCloseMOF_Click(object sender, EventArgs e) 22 | { 23 | this.Close(); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /WmiExplorer/Forms/Form_ShowMof.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /WmiExplorer/Forms/Form_Update.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace WmiExplorer.Forms 2 | { 3 | partial class Form_Update 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.richTextBoxUpdate = new System.Windows.Forms.RichTextBox(); 32 | this.buttonCancelHidden = new System.Windows.Forms.Button(); 33 | this.SuspendLayout(); 34 | // 35 | // richTextBoxUpdate 36 | // 37 | this.richTextBoxUpdate.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 38 | | System.Windows.Forms.AnchorStyles.Left) 39 | | System.Windows.Forms.AnchorStyles.Right))); 40 | this.richTextBoxUpdate.BorderStyle = System.Windows.Forms.BorderStyle.None; 41 | this.richTextBoxUpdate.Cursor = System.Windows.Forms.Cursors.IBeam; 42 | this.richTextBoxUpdate.Location = new System.Drawing.Point(12, 12); 43 | this.richTextBoxUpdate.Name = "richTextBoxUpdate"; 44 | this.richTextBoxUpdate.ReadOnly = true; 45 | this.richTextBoxUpdate.Size = new System.Drawing.Size(471, 156); 46 | this.richTextBoxUpdate.TabIndex = 0; 47 | this.richTextBoxUpdate.Text = ""; 48 | this.richTextBoxUpdate.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this.richTextBoxUpdate_LinkClicked); 49 | // 50 | // buttonCancelHidden 51 | // 52 | this.buttonCancelHidden.Anchor = System.Windows.Forms.AnchorStyles.Bottom; 53 | this.buttonCancelHidden.DialogResult = System.Windows.Forms.DialogResult.Cancel; 54 | this.buttonCancelHidden.Location = new System.Drawing.Point(193, 174); 55 | this.buttonCancelHidden.Name = "buttonCancelHidden"; 56 | this.buttonCancelHidden.Size = new System.Drawing.Size(100, 25); 57 | this.buttonCancelHidden.TabIndex = 1; 58 | this.buttonCancelHidden.Text = "OK"; 59 | this.buttonCancelHidden.UseVisualStyleBackColor = true; 60 | this.buttonCancelHidden.Click += new System.EventHandler(this.button1_Click); 61 | // 62 | // Form_Update 63 | // 64 | this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); 65 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; 66 | this.AutoSize = true; 67 | this.CancelButton = this.buttonCancelHidden; 68 | this.ClientSize = new System.Drawing.Size(484, 211); 69 | this.Controls.Add(this.richTextBoxUpdate); 70 | this.Controls.Add(this.buttonCancelHidden); 71 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; 72 | this.MaximizeBox = false; 73 | this.MinimizeBox = false; 74 | this.Name = "Form_Update"; 75 | this.ShowInTaskbar = false; 76 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; 77 | this.Text = "WMI Explorer Update"; 78 | this.ResumeLayout(false); 79 | 80 | } 81 | 82 | #endregion 83 | 84 | private System.Windows.Forms.RichTextBox richTextBoxUpdate; 85 | private System.Windows.Forms.Button buttonCancelHidden; 86 | } 87 | } -------------------------------------------------------------------------------- /WmiExplorer/Forms/Form_Update.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Drawing; 4 | using System.Windows.Forms; 5 | using WmiExplorer.Properties; 6 | 7 | namespace WmiExplorer.Forms 8 | { 9 | public partial class Form_Update : Form 10 | { 11 | public Form_Update(bool bUpdateAvailable, string changelog) 12 | { 13 | InitializeComponent(); 14 | 15 | if (bUpdateAvailable) 16 | { 17 | Font font = new Font("Arial", 10, FontStyle.Bold); 18 | richTextBoxUpdate.SelectionFont = font; 19 | richTextBoxUpdate.AppendText("A new version of WMI Explorer is available!\n"); 20 | richTextBoxUpdate.AppendText(Settings.Default.UpdateUrl + "\n\n"); 21 | richTextBoxUpdate.AppendText(changelog); 22 | richTextBoxUpdate.SelectionStart = 0; 23 | richTextBoxUpdate.ScrollToCaret(); 24 | } 25 | else 26 | { 27 | Width = 400; 28 | Height = 200; 29 | richTextBoxUpdate.AppendText("You are running the latest version!"); 30 | } 31 | } 32 | 33 | private void button1_Click(object sender, EventArgs e) 34 | { 35 | Close(); 36 | } 37 | 38 | private void richTextBoxUpdate_LinkClicked(object sender, LinkClickedEventArgs e) 39 | { 40 | Process.Start(e.LinkText); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /WmiExplorer/Forms/Form_Update.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /WmiExplorer/Icons/Database CMYK .ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinaypamnani/wmie2/744a9f997f33765830023a8f660c95506b96d75d/WmiExplorer/Icons/Database CMYK .ico -------------------------------------------------------------------------------- /WmiExplorer/Icons/Icojam-Blue-Bits-Database-search.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinaypamnani/wmie2/744a9f997f33765830023a8f660c95506b96d75d/WmiExplorer/Icons/Icojam-Blue-Bits-Database-search.ico -------------------------------------------------------------------------------- /WmiExplorer/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Windows.Forms; 5 | 6 | namespace WmiExplorer 7 | { 8 | static class Program 9 | { 10 | /// 11 | /// The main entry point for the application. 12 | /// 13 | [STAThread] 14 | static void Main() 15 | { 16 | if (Environment.OSVersion.Version.Major >= 6) SetProcessDPIAware(); 17 | Application.EnableVisualStyles(); 18 | Application.SetCompatibleTextRenderingDefault(false); 19 | Application.Run(new WmiExplorer()); 20 | } 21 | 22 | [System.Runtime.InteropServices.DllImport("user32.dll")] 23 | private static extern bool SetProcessDPIAware(); 24 | 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /WmiExplorer/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("WMI Explorer")] 9 | [assembly: AssemblyDescription("WMI Explorer is a utility intended to provide the ability to browse and view WMI objects in a single pane of view.")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("WMI Explorer")] 13 | [assembly: AssemblyCopyright("Copyright © 2014 by Vinay Pamnani")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("0186a05f-638a-4422-9992-412b499e60e4")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("2.0.0.2")] 36 | [assembly: AssemblyFileVersion("2.0.0.2")] 37 | -------------------------------------------------------------------------------- /WmiExplorer/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.34014 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace WmiExplorer.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WmiExplorer.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /WmiExplorer/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /WmiExplorer/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace WmiExplorer.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | 26 | [global::System.Configuration.UserScopedSettingAttribute()] 27 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 28 | [global::System.Configuration.DefaultSettingValueAttribute("False")] 29 | public bool bCheckForUpdates { 30 | get { 31 | return ((bool)(this["bCheckForUpdates"])); 32 | } 33 | set { 34 | this["bCheckForUpdates"] = value; 35 | } 36 | } 37 | 38 | [global::System.Configuration.UserScopedSettingAttribute()] 39 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 40 | [global::System.Configuration.DefaultSettingValueAttribute("True")] 41 | public bool bPreserveLayout { 42 | get { 43 | return ((bool)(this["bPreserveLayout"])); 44 | } 45 | set { 46 | this["bPreserveLayout"] = value; 47 | } 48 | } 49 | 50 | [global::System.Configuration.UserScopedSettingAttribute()] 51 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 52 | [global::System.Configuration.DefaultSettingValueAttribute("True")] 53 | public bool bRememberEnumOptions { 54 | get { 55 | return ((bool)(this["bRememberEnumOptions"])); 56 | } 57 | set { 58 | this["bRememberEnumOptions"] = value; 59 | } 60 | } 61 | 62 | [global::System.Configuration.UserScopedSettingAttribute()] 63 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 64 | [global::System.Configuration.DefaultSettingValueAttribute("True")] 65 | public bool bRememberRecentPaths { 66 | get { 67 | return ((bool)(this["bRememberRecentPaths"])); 68 | } 69 | set { 70 | this["bRememberRecentPaths"] = value; 71 | } 72 | } 73 | 74 | [global::System.Configuration.UserScopedSettingAttribute()] 75 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 76 | [global::System.Configuration.DefaultSettingValueAttribute("False")] 77 | public bool bUpdateAvailable { 78 | get { 79 | return ((bool)(this["bUpdateAvailable"])); 80 | } 81 | set { 82 | this["bUpdateAvailable"] = value; 83 | } 84 | } 85 | 86 | [global::System.Configuration.UserScopedSettingAttribute()] 87 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 88 | [global::System.Configuration.DefaultSettingValueAttribute("True")] 89 | public bool bUpgradeSettings { 90 | get { 91 | return ((bool)(this["bUpgradeSettings"])); 92 | } 93 | set { 94 | this["bUpgradeSettings"] = value; 95 | } 96 | } 97 | 98 | [global::System.Configuration.UserScopedSettingAttribute()] 99 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 100 | [global::System.Configuration.DefaultSettingValueAttribute("60")] 101 | public string CacheAgeInMinutes { 102 | get { 103 | return ((string)(this["CacheAgeInMinutes"])); 104 | } 105 | set { 106 | this["CacheAgeInMinutes"] = value; 107 | } 108 | } 109 | 110 | [global::System.Configuration.UserScopedSettingAttribute()] 111 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 112 | [global::System.Configuration.DefaultSettingValueAttribute("None")] 113 | public global::WmiExplorer.Classes.EnumOptions EnumOptionsFlags { 114 | get { 115 | return ((global::WmiExplorer.Classes.EnumOptions)(this["EnumOptionsFlags"])); 116 | } 117 | set { 118 | this["EnumOptionsFlags"] = value; 119 | } 120 | } 121 | 122 | [global::System.Configuration.UserScopedSettingAttribute()] 123 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 124 | [global::System.Configuration.DefaultSettingValueAttribute("1970-01-01")] 125 | public global::System.DateTime LastUpdateCheck { 126 | get { 127 | return ((global::System.DateTime)(this["LastUpdateCheck"])); 128 | } 129 | set { 130 | this["LastUpdateCheck"] = value; 131 | } 132 | } 133 | 134 | [global::System.Configuration.UserScopedSettingAttribute()] 135 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 136 | public global::System.Collections.Specialized.StringCollection RecentPaths { 137 | get { 138 | return ((global::System.Collections.Specialized.StringCollection)(this["RecentPaths"])); 139 | } 140 | set { 141 | this["RecentPaths"] = value; 142 | } 143 | } 144 | 145 | [global::System.Configuration.UserScopedSettingAttribute()] 146 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 147 | [global::System.Configuration.DefaultSettingValueAttribute("220")] 148 | public int SplitterDistanceNamespaces { 149 | get { 150 | return ((int)(this["SplitterDistanceNamespaces"])); 151 | } 152 | set { 153 | this["SplitterDistanceNamespaces"] = value; 154 | } 155 | } 156 | 157 | [global::System.Configuration.UserScopedSettingAttribute()] 158 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 159 | [global::System.Configuration.DefaultSettingValueAttribute("200")] 160 | public int SplitterDistanceClasses { 161 | get { 162 | return ((int)(this["SplitterDistanceClasses"])); 163 | } 164 | set { 165 | this["SplitterDistanceClasses"] = value; 166 | } 167 | } 168 | 169 | [global::System.Configuration.UserScopedSettingAttribute()] 170 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 171 | [global::System.Configuration.DefaultSettingValueAttribute("180")] 172 | public int SplitterDistanceInstances { 173 | get { 174 | return ((int)(this["SplitterDistanceInstances"])); 175 | } 176 | set { 177 | this["SplitterDistanceInstances"] = value; 178 | } 179 | } 180 | 181 | [global::System.Configuration.UserScopedSettingAttribute()] 182 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 183 | [global::System.Configuration.DefaultSettingValueAttribute("7")] 184 | public string UpdateCheckIntervalInDays { 185 | get { 186 | return ((string)(this["UpdateCheckIntervalInDays"])); 187 | } 188 | set { 189 | this["UpdateCheckIntervalInDays"] = value; 190 | } 191 | } 192 | 193 | [global::System.Configuration.ApplicationScopedSettingAttribute()] 194 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 195 | [global::System.Configuration.DefaultSettingValueAttribute("https://raw.githubusercontent.com/vinaypamnani/wmie2/master/WmiExplorer/releases." + 196 | "xml")] 197 | public string UpdateCheckUrl { 198 | get { 199 | return ((string)(this["UpdateCheckUrl"])); 200 | } 201 | } 202 | 203 | [global::System.Configuration.ApplicationScopedSettingAttribute()] 204 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 205 | [global::System.Configuration.DefaultSettingValueAttribute("http://wmie.azurewebsites.net/releases.xml")] 206 | public string UpdateCheckUrlBackup { 207 | get { 208 | return ((string)(this["UpdateCheckUrlBackup"])); 209 | } 210 | } 211 | 212 | [global::System.Configuration.UserScopedSettingAttribute()] 213 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 214 | [global::System.Configuration.DefaultSettingValueAttribute("https://github.com/vinaypamnani/wmie2/releases")] 215 | public string UpdateUrl { 216 | get { 217 | return ((string)(this["UpdateUrl"])); 218 | } 219 | set { 220 | this["UpdateUrl"] = value; 221 | } 222 | } 223 | 224 | [global::System.Configuration.UserScopedSettingAttribute()] 225 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 226 | [global::System.Configuration.DefaultSettingValueAttribute("")] 227 | public string WindowPlacement { 228 | get { 229 | return ((string)(this["WindowPlacement"])); 230 | } 231 | set { 232 | this["WindowPlacement"] = value; 233 | } 234 | } 235 | 236 | [global::System.Configuration.UserScopedSettingAttribute()] 237 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 238 | [global::System.Configuration.DefaultSettingValueAttribute("True")] 239 | public bool bEnumModeAsync { 240 | get { 241 | return ((bool)(this["bEnumModeAsync"])); 242 | } 243 | set { 244 | this["bEnumModeAsync"] = value; 245 | } 246 | } 247 | 248 | [global::System.Configuration.UserScopedSettingAttribute()] 249 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 250 | [global::System.Configuration.DefaultSettingValueAttribute("True")] 251 | public bool bSmsMode { 252 | get { 253 | return ((bool)(this["bSmsMode"])); 254 | } 255 | set { 256 | this["bSmsMode"] = value; 257 | } 258 | } 259 | } 260 | } 261 | -------------------------------------------------------------------------------- /WmiExplorer/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | False 7 | 8 | 9 | True 10 | 11 | 12 | True 13 | 14 | 15 | True 16 | 17 | 18 | False 19 | 20 | 21 | True 22 | 23 | 24 | 60 25 | 26 | 27 | None 28 | 29 | 30 | 1970-01-01 31 | 32 | 33 | 34 | 35 | 36 | 220 37 | 38 | 39 | 200 40 | 41 | 42 | 180 43 | 44 | 45 | 7 46 | 47 | 48 | https://raw.githubusercontent.com/vinaypamnani/wmie2/master/WmiExplorer/releases.xml 49 | 50 | 51 | http://wmie.azurewebsites.net/releases.xml 52 | 53 | 54 | https://github.com/vinaypamnani/wmie2/releases 55 | 56 | 57 | 58 | 59 | 60 | True 61 | 62 | 63 | True 64 | 65 | 66 | -------------------------------------------------------------------------------- /WmiExplorer/Sms/SmsClient.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System.Management; 3 | 4 | namespace WmiExplorer.Sms 5 | { 6 | public class SmsClient 7 | { 8 | public SmsClient(string clientNamespacePath, ConnectionOptions connection) 9 | { 10 | ClientNamespacePath = clientNamespacePath; 11 | SmsClientClassPath = clientNamespacePath + ":SMS_Client"; 12 | Connection = connection; 13 | IsClientInstalled = IsInstalled(); 14 | } 15 | 16 | public string ClientNamespacePath { get; set; } 17 | 18 | public ConnectionOptions Connection { get; set; } 19 | 20 | public bool IsClientInstalled { get; set; } 21 | 22 | public bool IsConnected { get; set; } 23 | 24 | public ManagementClass SmsClientClass { get; set; } 25 | 26 | public string SmsClientClassPath { get; set; } 27 | 28 | public bool IsInstalled() 29 | { 30 | const string queryString = "SELECT * FROM meta_class WHERE __Class = 'SMS_Client'"; 31 | 32 | ManagementScope scope = new ManagementScope(ClientNamespacePath, Connection); 33 | ObjectQuery query = new ObjectQuery(queryString); 34 | EnumerationOptions eOption = new EnumerationOptions(); 35 | ManagementObjectSearcher queryClientSearcher = new ManagementObjectSearcher(scope, query, eOption); 36 | 37 | ManagementObject ccmClient = (from ManagementClass mClass in queryClientSearcher.Get() 38 | orderby mClass.Path.ClassName 39 | select mClass).FirstOrDefault(); 40 | 41 | return ccmClient != null; 42 | } 43 | 44 | //public void InitiateClientAction(SmsClientAction smsClientAction) 45 | //{ 46 | // try 47 | // { 48 | // ManagementBaseObject inParams = SmsClientClass.GetMethodParameters("TriggerSchedule"); 49 | // inParams["sScheduleId"] = smsClientAction.Id; 50 | // ManagementBaseObject outParams = SmsClientClass.InvokeMethod("TriggerSchedule", inParams, null); 51 | 52 | // if (outParams != null) 53 | // { 54 | // MessageBox.Show("Successfully triggered " + smsClientAction.DisplayName + ".", 55 | // "Initiate Client Action", 56 | // MessageBoxButtons.OK, 57 | // MessageBoxIcon.Information); 58 | // } 59 | // } 60 | // catch (Exception ex) 61 | // { 62 | // MessageBox.Show("Failed to trigger " + smsClientAction.DisplayName + ". Error: " + ex.Message, 63 | // "Initiate Client Action", 64 | // MessageBoxButtons.OK, 65 | // MessageBoxIcon.Error); 66 | // } 67 | //} 68 | } 69 | } -------------------------------------------------------------------------------- /WmiExplorer/Sms/SmsClientAction.cs: -------------------------------------------------------------------------------- 1 | namespace WmiExplorer.Sms 2 | { 3 | public static class ActionGroup 4 | { 5 | public static string ApplicationEvaluation = "Application Evaluation"; 6 | public static string Default = "Default"; 7 | public static string Endpoint = "Endpoint Protection"; 8 | public static string Inventory = "Inventory"; 9 | public static string LocationServices = "Location Services"; 10 | public static string Other = "Other"; 11 | public static string Policy = "Policy"; 12 | public static string SoftwareUpdates = "Software Updates"; 13 | public static string StateMessage = "State Messages"; 14 | } 15 | 16 | public class SmsClientAction 17 | { 18 | public SmsClientAction(string id, string displayName, string group = "Default") 19 | { 20 | Id = id; 21 | DisplayName = displayName; 22 | Group = group; 23 | } 24 | 25 | public string DisplayName { get; set; } 26 | 27 | public string Group { get; set; } 28 | 29 | public string Id { get; set; } 30 | } 31 | } -------------------------------------------------------------------------------- /WmiExplorer/Sms/SmsClientActions.cs: -------------------------------------------------------------------------------- 1 | namespace WmiExplorer.Sms 2 | { 3 | internal class SmsClientActions 4 | { 5 | public SmsClientActions() 6 | { 7 | } 8 | 9 | public static SmsClientAction HardwareInventory 10 | { 11 | // {00000000-0000-0000-0000-000000000101} is the same 12 | get { return new SmsClientAction("{00000000-0000-0000-0000-000000000001}", "Hardware Inventory Cycle", ActionGroup.Inventory); } 13 | } 14 | 15 | public static SmsClientAction SoftwareInventory 16 | { 17 | // {00000000-0000-0000-0000-000000000102} is the same 18 | get { return new SmsClientAction("{00000000-0000-0000-0000-000000000002}", "Software Inventory Cycle", ActionGroup.Inventory); } 19 | } 20 | 21 | public static SmsClientAction HeartbeatDiscovery 22 | { 23 | // {00000000-0000-0000-0000-000000000103} is the same 24 | get { return new SmsClientAction("{00000000-0000-0000-0000-000000000003}", "Discovery Data Collection Cycle", ActionGroup.Inventory); } 25 | } 26 | 27 | public static SmsClientAction FileCollection 28 | { 29 | // {00000000-0000-0000-0000-000000000104} is the same 30 | get { return new SmsClientAction("{00000000-0000-0000-0000-000000000010}", "File Collection Cycle", ActionGroup.Inventory); } 31 | } 32 | 33 | public static SmsClientAction IdmifCollection 34 | { 35 | // {00000000-0000-0000-0000-000000000105} is the same 36 | get { return new SmsClientAction("{00000000-0000-0000-0000-000000000011}", "IDMIF Collection Cycle", ActionGroup.Inventory); } 37 | } 38 | 39 | public static SmsClientAction ClientMachineAuthentication 40 | { 41 | get { return new SmsClientAction("{00000000-0000-0000-0000-000000000012}", "Client Machine Authentication", ActionGroup.Other); } 42 | } 43 | 44 | public static SmsClientAction MachineAssignmentsRequest 45 | { 46 | get { return new SmsClientAction("{00000000-0000-0000-0000-000000000021}", "Request Machine Assignments", ActionGroup.Policy); } 47 | } 48 | 49 | public static SmsClientAction MachineAssignmentsEvaluate 50 | { 51 | get { return new SmsClientAction("{00000000-0000-0000-0000-000000000022}", "Evaluate Machine Assignments", ActionGroup.Policy); } 52 | } 53 | 54 | public static SmsClientAction LocationRefreshDefaultMp 55 | { 56 | get { return new SmsClientAction("{00000000-0000-0000-0000-000000000023}", "Refresh Default MP", ActionGroup.LocationServices); } 57 | } 58 | 59 | public static SmsClientAction LocationRefreshLocations 60 | { 61 | get { return new SmsClientAction("{00000000-0000-0000-0000-000000000024}", "Refresh Locations", ActionGroup.LocationServices); } 62 | } 63 | 64 | public static SmsClientAction LocationTimeoutRefresh 65 | { 66 | get { return new SmsClientAction("{00000000-0000-0000-0000-000000000025}", "Timeout Refresh", ActionGroup.LocationServices); } 67 | } 68 | 69 | public static SmsClientAction UserAssignmentsRequest 70 | { 71 | get { return new SmsClientAction("{00000000-0000-0000-0000-000000000026}", "Request User Assignments", ActionGroup.Policy); } 72 | } 73 | 74 | public static SmsClientAction UserAssignmentsEvaluate 75 | { 76 | get { return new SmsClientAction("{00000000-0000-0000-0000-000000000027}", "Evaluate User Assignments", ActionGroup.Policy); } 77 | } 78 | 79 | public static SmsClientAction SoftwareMeterUsageReport 80 | { 81 | // {00000000-0000-0000-0000-000000000106} 82 | get { return new SmsClientAction("{00000000-0000-0000-0000-000000000031}", "Software Metering Usage Report Cycle", ActionGroup.Inventory); } 83 | } 84 | 85 | public static SmsClientAction SourceUpdateCycle 86 | { 87 | // {00000000-0000-0000-0000-000000000107} 88 | get { return new SmsClientAction("{00000000-0000-0000-0000-000000000032}", "Windows Installer Source List Update Cycle", ActionGroup.Other); } 89 | } 90 | 91 | public static SmsClientAction ProxySettingsCacheClear 92 | { 93 | get { return new SmsClientAction("{00000000-0000-0000-0000-000000000037}", "Clear Proxy Settings Cache", ActionGroup.Other); } 94 | } 95 | 96 | public static SmsClientAction PolicyAgentCleanupMachine 97 | { 98 | get { return new SmsClientAction("{00000000-0000-0000-0000-000000000040}", "Policy Agent Cleanup Cycle (Machine)", ActionGroup.Policy); } 99 | } 100 | 101 | public static SmsClientAction PolicyAgentCleanupUser 102 | { 103 | get { return new SmsClientAction("{00000000-0000-0000-0000-000000000041}", "Policy Agent Cleanup Cycle (User)", ActionGroup.Policy); } 104 | } 105 | 106 | public static SmsClientAction PolicyAgentValidateMachine 107 | { 108 | get { return new SmsClientAction("{00000000-0000-0000-0000-000000000042}", "Validate Machine Policy/Assignment", ActionGroup.Policy); } 109 | } 110 | 111 | public static SmsClientAction PolicyAgentValidateUser 112 | { 113 | get { return new SmsClientAction("{00000000-0000-0000-0000-000000000043}", "Validate User Policy/Assignment", ActionGroup.Policy); } 114 | } 115 | 116 | public static SmsClientAction RetryRefreshCertificate 117 | { 118 | get { return new SmsClientAction("{00000000-0000-0000-0000-000000000051}", "Retry/Refresh Certificates in AD on MP", ActionGroup.Other); } 119 | } 120 | 121 | public static SmsClientAction SoftwareUpdateInstallSchedule 122 | { 123 | get { return new SmsClientAction("{00000000-0000-0000-0000-000000000063}", "Software Updates Install Schedule", ActionGroup.SoftwareUpdates); } 124 | } 125 | 126 | public static SmsClientAction Nap 127 | { 128 | get { return new SmsClientAction("{00000000-0000-0000-0000-000000000071}", "Network Access Protection Schedule", ActionGroup.Other); } 129 | } 130 | 131 | public static SmsClientAction SoftwareUpdateAssignmentEvaluation 132 | { 133 | get { return new SmsClientAction("{00000000-0000-0000-0000-000000000108}", "Software Updates Assignment Evaluation Cycle", ActionGroup.SoftwareUpdates); } 134 | } 135 | 136 | public static SmsClientAction DcmPolicy 137 | { 138 | get { return new SmsClientAction("{00000000-0000-0000-0000-000000000110}", "DCM Policy", ActionGroup.Other); } 139 | } 140 | 141 | public static SmsClientAction StateMessageSendUnsent 142 | { 143 | get { return new SmsClientAction("{00000000-0000-0000-0000-000000000111}", "Send Unsent State Messages", ActionGroup.StateMessage); } 144 | } 145 | 146 | public static SmsClientAction StateMessagePolicyCacheClean 147 | { 148 | get { return new SmsClientAction("{00000000-0000-0000-0000-000000000112}", "State System Policy Cache Clean", ActionGroup.StateMessage); } 149 | } 150 | 151 | public static SmsClientAction SoftwareUpdateScan 152 | { 153 | get { return new SmsClientAction("{00000000-0000-0000-0000-000000000113}", "Software Update Scan Cycle", ActionGroup.SoftwareUpdates); } 154 | } 155 | 156 | public static SmsClientAction SoftwareUpdateStore 157 | { 158 | get { return new SmsClientAction("{00000000-0000-0000-0000-000000000114}", "Software Update Store Refresh", ActionGroup.SoftwareUpdates); } 159 | } 160 | 161 | public static SmsClientAction StateMessageSendHigh 162 | { 163 | get { return new SmsClientAction("{00000000-0000-0000-0000-000000000115}", "Bulk Send High Priority", ActionGroup.StateMessage); } 164 | } 165 | 166 | public static SmsClientAction StateMessageSendLow 167 | { 168 | get { return new SmsClientAction("{00000000-0000-0000-0000-000000000116}", "Bulk Send Low Priority", ActionGroup.StateMessage); } 169 | } 170 | 171 | public static SmsClientAction AmtStatusCheck 172 | { 173 | get { return new SmsClientAction("{00000000-0000-0000-0000-000000000120}", "AMT Status Check Policy", ActionGroup.Other); } 174 | } 175 | 176 | public static SmsClientAction ApplicationPolicy 177 | { 178 | get { return new SmsClientAction("{00000000-0000-0000-0000-000000000121}", "Application Manager Machine Policy", ActionGroup.ApplicationEvaluation); } 179 | } 180 | 181 | public static SmsClientAction ApplicationPolicyUser 182 | { 183 | get { return new SmsClientAction("{00000000-0000-0000-0000-000000000122}", "Application Manager User Policy", ActionGroup.ApplicationEvaluation); } 184 | } 185 | 186 | public static SmsClientAction ApplicationPolicyGlobal 187 | { 188 | get { return new SmsClientAction("{00000000-0000-0000-0000-000000000123}", "Application Manager Global Evaluation Policy", ActionGroup.ApplicationEvaluation); } 189 | } 190 | 191 | public static SmsClientAction PowerMgmtSummarize 192 | { 193 | get { return new SmsClientAction("{00000000-0000-0000-0000-000000000131}", "Power Management Summarizer", ActionGroup.Other); } 194 | } 195 | 196 | public static SmsClientAction EpDeploymentReevaluate 197 | { 198 | get { return new SmsClientAction("{00000000-0000-0000-0000-000000000221}", "Endpoint Protection Deployment Re-Evaluate", ActionGroup.Endpoint); } 199 | } 200 | 201 | public static SmsClientAction EpAmPolicyReevaluate 202 | { 203 | get { return new SmsClientAction("{00000000-0000-0000-0000-000000000222}", "Endpoint Protection AM Policy Re-Evaluate", ActionGroup.Endpoint); } 204 | } 205 | 206 | // Excluded Actions: 207 | // {00000000-0000-0000-0000-000000000061} 208 | // {00000000-0000-0000-0000-000000000062} 209 | // {00000000-0000-0000-0000-000000000101} 210 | // {00000000-0000-0000-0000-000000000109} 211 | // {00000000-0000-0000-0000-000000000223} 212 | } 213 | } -------------------------------------------------------------------------------- /WmiExplorer/Updater/Update.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace WmiExplorer.Updater 4 | { 5 | internal class Update 6 | { 7 | public Uri ChangeLogUrl { get; set; } 8 | 9 | public DateTimeOffset LastUpdatedTime { get; set; } 10 | 11 | public ReleaseStatus ReleaseStatus { get; set; } 12 | 13 | public Uri Url { get; set; } 14 | 15 | public Version Version { get; set; } 16 | } 17 | } -------------------------------------------------------------------------------- /WmiExplorer/Updater/UpdateEnums.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace WmiExplorer.Updater 4 | { 5 | [Flags] 6 | public enum ReleaseStatus 7 | { 8 | None = 0, 9 | Stable = 1, 10 | Beta = 2, 11 | Alpha = 4 12 | } 13 | 14 | public enum UpdateFilter 15 | { 16 | None = 0, 17 | Stable = ReleaseStatus.Stable, 18 | Beta = Stable | ReleaseStatus.Beta, 19 | Alpha = Beta | ReleaseStatus.Alpha 20 | } 21 | } -------------------------------------------------------------------------------- /WmiExplorer/Updater/UpdaterService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Linq; 4 | using System.Net; 5 | using System.Reflection; 6 | using System.ServiceModel.Syndication; 7 | using System.Xml; 8 | 9 | namespace WmiExplorer.Updater 10 | { 11 | internal class UpdaterService 12 | { 13 | public static Update GetUpdateFromSyndicationItem(SyndicationItem item) 14 | { 15 | Debug.Assert(item != null); 16 | 17 | var update = new Update(); 18 | 19 | // Update Version 20 | Version version; 21 | if (Version.TryParse(item.Title.Text, out version)) 22 | { 23 | update.Version = version; 24 | } 25 | 26 | // Last Updated Time 27 | update.LastUpdatedTime = item.LastUpdatedTime; 28 | 29 | // Update Url 30 | var updateLink = item.Links.FirstOrDefault( 31 | l => String.IsNullOrWhiteSpace(l.RelationshipType) 32 | || l.RelationshipType.Equals("alternate", StringComparison.OrdinalIgnoreCase)); 33 | 34 | if (updateLink != null) 35 | { 36 | update.Url = updateLink.GetAbsoluteUri(); 37 | } 38 | 39 | // Change Log Url 40 | var changeLogLink = item.Links.FirstOrDefault( 41 | l => String.IsNullOrWhiteSpace(l.RelationshipType) 42 | || l.RelationshipType.Equals("related", StringComparison.OrdinalIgnoreCase)); 43 | 44 | if (changeLogLink != null) 45 | { 46 | update.ChangeLogUrl = changeLogLink.GetAbsoluteUri(); 47 | } 48 | 49 | // Update Release Status 50 | update.ReleaseStatus 51 | = item.Categories.Aggregate( 52 | ReleaseStatus.None, 53 | (rs, c) => 54 | { 55 | ReleaseStatus releaseStatus; 56 | 57 | if (Enum.TryParse(c.Name, true, out releaseStatus)) 58 | { 59 | rs |= releaseStatus; 60 | } 61 | 62 | return rs; 63 | }); 64 | 65 | return update; 66 | } 67 | 68 | public Update CheckForUpdatesAsync(string updateUrl, UpdateFilter updateFilter) 69 | { 70 | Debug.Assert(!String.IsNullOrWhiteSpace(updateUrl)); 71 | 72 | Update latestUpdate = null; 73 | 74 | var formatter = new Atom10FeedFormatter(); 75 | var reader = XmlReader.Create(updateUrl); 76 | formatter.ReadFrom(reader); 77 | 78 | latestUpdate = (from i in formatter.Feed.Items 79 | let u = GetUpdateFromSyndicationItem(i) 80 | where u.Version > Assembly.GetExecutingAssembly().GetName().Version 81 | && ((int)updateFilter & (int)u.ReleaseStatus) != 0 82 | orderby u.LastUpdatedTime descending 83 | select u).FirstOrDefault(); 84 | 85 | return latestUpdate; 86 | } 87 | 88 | public string GetChangeLog(Uri changeLogUrl) 89 | { 90 | return new WebClient().DownloadString(changeLogUrl); 91 | } 92 | } 93 | } -------------------------------------------------------------------------------- /WmiExplorer/WmiExplorer.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {781647DE-1788-4B7C-9289-D0323FDF562A} 8 | WinExe 9 | Properties 10 | WmiExplorer 11 | WmiExplorer 12 | v4.0 13 | 512 14 | publish\ 15 | true 16 | Disk 17 | false 18 | Foreground 19 | 7 20 | Days 21 | false 22 | false 23 | true 24 | 0 25 | 1.0.0.%2a 26 | false 27 | false 28 | true 29 | SAK 30 | SAK 31 | SAK 32 | SAK 33 | 34 | 35 | AnyCPU 36 | true 37 | full 38 | false 39 | bin\Debug\ 40 | DEBUG;TRACE 41 | prompt 42 | 4 43 | 44 | 45 | 46 | 47 | AnyCPU 48 | pdbonly 49 | true 50 | bin\Release\ 51 | TRACE 52 | prompt 53 | 4 54 | 55 | 56 | 57 | Icons\Icojam-Blue-Bits-Database-search.ico 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | Form 93 | 94 | 95 | Form_About.cs 96 | 97 | 98 | Form 99 | 100 | 101 | Form_ConnectAs.cs 102 | 103 | 104 | Form 105 | 106 | 107 | Form_DisplayText.cs 108 | 109 | 110 | Form 111 | 112 | 113 | Form_ExecMethod.cs 114 | 115 | 116 | Form 117 | 118 | 119 | Form_Settings.cs 120 | 121 | 122 | Form 123 | 124 | 125 | Form_ShowMof.cs 126 | 127 | 128 | Form 129 | 130 | 131 | Form_Update.cs 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | Form 141 | 142 | 143 | WmiExplorer.cs 144 | 145 | 146 | WmiExplorer.cs 147 | 148 | 149 | 150 | 151 | Form_About.cs 152 | 153 | 154 | Form_ConnectAs.cs 155 | 156 | 157 | Form_DisplayText.cs 158 | 159 | 160 | Form_ExecMethod.cs 161 | 162 | 163 | Form_Settings.cs 164 | 165 | 166 | Form_ShowMof.cs 167 | 168 | 169 | Form_Update.cs 170 | 171 | 172 | ResXFileCodeGenerator 173 | Resources.Designer.cs 174 | Designer 175 | 176 | 177 | True 178 | Resources.resx 179 | True 180 | 181 | 182 | WmiExplorer.cs 183 | 184 | 185 | 186 | SettingsSingleFileGenerator 187 | Settings.Designer.cs 188 | 189 | 190 | True 191 | Settings.settings 192 | True 193 | 194 | 195 | 196 | 197 | False 198 | Microsoft .NET Framework 4 %28x86 and x64%29 199 | true 200 | 201 | 202 | False 203 | .NET Framework 3.5 SP1 Client Profile 204 | false 205 | 206 | 207 | False 208 | .NET Framework 3.5 SP1 209 | false 210 | 211 | 212 | False 213 | Windows Installer 4.5 214 | true 215 | 216 | 217 | 218 | 219 | PreserveNewest 220 | 221 | 222 | 223 | 224 | Designer 225 | 226 | 227 | 228 | 229 | 230 | 237 | -------------------------------------------------------------------------------- /WmiExplorer/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 |
6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | False 15 | 16 | 17 | True 18 | 19 | 20 | True 21 | 22 | 23 | True 24 | 25 | 26 | False 27 | 28 | 29 | True 30 | 31 | 32 | 60 33 | 34 | 35 | None 36 | 37 | 38 | 1970-01-01 39 | 40 | 41 | 220 42 | 43 | 44 | 200 45 | 46 | 47 | 180 48 | 49 | 50 | 7 51 | 52 | 53 | https://github.com/vinaypamnani/wmie2/releases 54 | 55 | 56 | 57 | 58 | 59 | True 60 | 61 | 62 | True 63 | 64 | 65 | 66 | 67 | 68 | 69 | https://raw.githubusercontent.com/vinaypamnani/wmie2/master/WmiExplorer/releases.xml 70 | 71 | 72 | http://wmie.azurewebsites.net/releases.xml 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /WmiExplorer/releases.azure.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | WMI Explorer 4 | https://github.com/vinaypamnani/wmie2/releases 5 | 2017-10-05T00:00:00Z 6 | 7 | Vinay Pamnani 8 | 9 | 10 | https://github.com/vinaypamnani/wmie2/releases 11 | 2.0.0.2 12 | 2017-10-05T00:00:00Z 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /WmiExplorer/releases.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | WMI Explorer 4 | https://github.com/vinaypamnani/wmie2/releases 5 | 2017-10-05T00:00:00Z 6 | 7 | Vinay Pamnani 8 | 9 | 10 | https://github.com/vinaypamnani/wmie2/releases 11 | 2.0.0.2 12 | 2017-10-05T00:00:00Z 13 | 14 | 15 | 16 | 17 | --------------------------------------------------------------------------------