Obtain the list of installed programs

Source: Internet
Author: User
  1. How to list all applications installed on a specific computer?
  2. The win32_product WMI class represents all applications installed through Windows installer. However, this WMI class may not list all the programs that appear in 'add/delete project. One way to solve this problem is to collect information about installed programs from the Registry (Note: not all programs write information to the Registry during installation ). This topic provides two methods to achieve this goal: use scripts to directly read information in the registry, and use MOF files and scripts to obtain this information from WMI.
  3. 1.
  4. Run the following script to list the applications installed on your computer. Script for directly collecting information from the Registry Using WMI system registry provider:
  5. Strhost = "."
  6. Const HKLM = & h80000002
  7. Set objreg = GetObject ("winmgmts: //" & strhost &_
  8. "/Root/Default: stdregprov ")
  9. Const strbasekey = _
  10. "Software/Microsoft/Windows/CurrentVersion/uninstall /"
  11. Objreg. enumkey HKLM, strbasekey, arrsubkeys
  12. For each strsubkey in arrsubkeys
  13. Intret = objreg. getstringvalue (HKLM, strbasekey & strsubkey ,_
  14. "Displayname", strvalue)
  15. If intret <> 0 then
  16. Intret = objreg. getstringvalue (HKLM, strbasekey & strsubkey ,_
  17. "Quietdisplayname", strvalue)
  18. End if
  19. If (strvalue <> "") and (intret = 0) then
  20. Wscript. Echo strvalue
  21. End if
  22. Next
  23. 2.
  24. The following MOF file and its supporting script demonstrate another method for obtaining installed applications from the registry. To use a MOF file, follow these steps:
  25. Step 1: copy the following MOF syntax to notepad and save it as a. mof file (for example, products. MOF ).
  26. Qualifier dynamic: toinstance;
  27. Qualifier providerclsid: toinstance;
  28. Qualifier classcontext: toinstance;
  29. Qualifier propertycontext: toinstance;
  30. [Dynamic, provider ("regprov "),
  31. Providerclsid ("{fe9af5c0-d3b6-11ce-a5b6-00aa00680c3f }"),
  32. Classcontext
  33. ("Local | HKEY_LOCAL_MACHINE // software // Microsoft // windows // CurrentVersion // Uninstall ")
  34. ]
  35. Class products {
  36. [Key] string keyname;
  37. [Read, propertycontext ("displayname")] string displayname;
  38. [Read, propertycontext ("displayversion")] string displayversion;
  39. [Read, propertycontext ("installlocation")] string installlocation;
  40. };
  41. Step 2: Enter mofcomp products. MOF in the command prompt line to save the MOF file to the WMI Repository.
  42. Step 3: Use the following script to obtain data after MOF is saved to the repository.
  43. Strcomputer = "."
  44. Set WMI = GetObject ("winmgmts: //" & strcomputer &_
  45. "/Root/Default ")
  46. Set colitems = WMI. execquery ("select * from products ")
  47. For each objitem in colitems
  48. Wscript. Echo "displayname:" & objitem. displayname
  49. Wscript. Echo "displayversion:" & objitem. displayversion
  50. Wscript. Echo "installlocation:" & objitem. installlocation
  51. Wscript. Echo "keyname:" & objitem. keyname
  52. Next

 

  1. Static void listalladdedapplication ()
  2. {
  3. Registrykey key = registry. localmachine. opensubkey (@ "software/Microsoft/Windows/CurrentVersion/uninstall ");
  4. Console. writeline ("subkeycount: {0}", key. subkeycount );
  5. // Key.
  6. String [] names = key. getsubkeynames ();
  7. Foreach (string s in names)
  8. {
  9. Console. writeline ("{0}", S );
  10. }
  11. }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.