How to construct WMI query

Try this: string wmiQuery = string.Format(“SELECT CommandLine FROM Win32_Process WHERE Name LIKE ‘{0}%{1}'”, param1, param2); Adding some test info: string wmiQuery = string.Format ( “SELECT Name, ProcessID FROM Win32_Process WHERE Name LIKE ‘{0}%{1}'”, “wpf”, “.exe” ); Console.WriteLine ( “Query: {0}”, wmiQuery ); ManagementObjectSearcher searcher = new ManagementObjectSearcher ( wmiQuery ); ManagementObjectCollection retObjectCollection = searcher.Get ( … Read more

Alternative to Win32_Product?

I use the registry remotely, without PSRemoting. Here’s the function I wrote and use daily to query software. Function Get-RemoteSoftware{ <# .SYNOPSIS Displays all software listed in the registry on a given computer. .DESCRIPTION Uses the SOFTWARE registry keys (both 32 and 64bit) to list the name, version, vendor, and uninstall string for each software … Read more