Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
152 views
in Technique[技术] by (71.8m points)

cruisecontrol.net - Finding ALL installed applications with PowerShell?

I am trying to use Windows PowerShell 2.0 to find an installed application. I have tried two methods, one using WMI and one using the Registry. Both methods are able to bring up a large list of installed applications and components, however neither one seems to bring up the application I am interested in.

I am specifically looking for CruiseControl.NET. It appears in the list of applications in the Programs and Features control panel applet. I know for a fact that it is currently installed, since I just uninstalled and reinstalled it to start fresh. Neither of the following methods seem to work, however (they succeed, but return no results):

Registry Search Approach

Looks in the registry HKLMSOFTWAREMicrosoftWindowsCurrentVersionUninstall for application keys. Returns plenty if I remove the where, but it is missing quite a few applications that do appear in the windows programs and features control panel.

gci "hklm:softwaremicrosoftwindowscurrentversionuninstall" 
    | foreach { gp $_.PSPath } 
    | select DisplayVersion,InstallDate,ModifyPath,Publisher,UninstallString,Language,DisplayName 
    | where { $_.DisplayName -match "^Cruise*" }

WMI Approach

Also returns plenty, however, based on the documentation for the Win32_Product object, they are only MSI installed applications. Many applications are missing, I'm guessing because they are not MSI. The CruiseControl.NET installer is the NSIS (NullSoft Installation System)...since it doesn't appear here, I am guessing that it doesn't use MSI at all, however I am curious if there is another way to use WMI to find ANY/ALL installed applications, regardless of whether they used MSI or not.

gwmi -namespace "rootcimv2" -class "Win32_Product" 
    | select Name,Vendor,Version,IdentifyingNumber 
    | where { $_.Name -match "^Cruise*" }

Finding the application via the registry does not do me a whole lot of good, really. Unless it also provides some way to find the applications uninstaller and the correct parameters to invoke it, which does not appear to always be the case. I would prefer to use WMI to find and uninstall the applications I need to uninstall, as that would not only allow me to use a single management interface for all of my scripts (WMI), but it should be easy for others to figure out how to maintain the scripts in the future since WMI is generally well documented.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Well, sorry to do this again. I had a bad habit of answering my own questions.

Anyway, I found the answer to my question by searching the registry for "CruiseControl.NET". It seems that 64bit versions of windows store Uninstall information in multiple places. Most notably, uninstall information seems to be primarily aggregated at the following key:

HKLM:SOFTWAREWow6432NodeMicrosoftWindowsCurrentVersionUninstall

I was able to find every program on my system listed here, including CruiseControl.NET. Note that this only seems to be the case on 64bit Windows Systems.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...