Detecting installed programs via registry

前端 未结 9 1612
清酒与你
清酒与你 2020-12-01 01:55

I need to develop a process that will detect if the users computer has certain programs installed and if so, what version. I believe I will need a list with the registry loc

相关标签:
9条回答
  • 2020-12-01 02:14

    On 64-bit systems the x64 key is:

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
    

    Most programs are listed there. Look at the keys: DisplayName DisplayVersion

    Note that the last is not always set!

    On 64-bit systems the x86 key (usually with more entries) is:

    HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall
    
    0 讨论(0)
  • 2020-12-01 02:15

    You could use MSI API to enumerate everything installed by Windows Installer but that won't list all the software available on a machine. Without knowing more about what you need I think the concept of "installed" is a little vague. There are many ways to deploy software to a system ranging from big complicated installers to ZIP files and everything in between.

    0 讨论(0)
  • 2020-12-01 02:17

    HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Compatibility Assistant\Persisted

    0 讨论(0)
  • 2020-12-01 02:18

    You can use a PowerShell script to look at registers and get the installed program details. The script bellow will generate a file with the complete list of installed programs. Save it with ".ps" extension and double click the file.

    #
    # Generates a full list of installed programs.
    #
    
    # Temporary auxiliar file.
    $tmpFile = "tmp.txt"
    
    # File that will hold the programs list.
    $fileName = "programas-instalados.txt"
    
    # Columns separator.
    $separator = ","
    
    # Delete previous files.
    Remove-Item $tmpFile
    Remove-Item $fileName
    
    # Creates the temporary file.
    Create-Item $tmpFile
    
    # Searchs register for programs - part 1
    $loc = Get-ChildItem HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall
    $names = $loc |foreach-object {Get-ItemProperty $_.PsPath}
    foreach ($name in $names)
    {
        IF(-Not [string]::IsNullOrEmpty($name.DisplayName)) {      
            $line = $name.DisplayName+$separator+$name.DisplayVersion+$separator+$name.InstallDate
            Write-Host $line
            Add-Content $tmpFile "$line`n"        
        }
    }
    
    # Searchs register for programs - part 2
    $loc = Get-ChildItem HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall
    $names = $loc |foreach-object {Get-ItemProperty $_.PsPath}
    foreach ($name in $names)
    {
        IF(-Not [string]::IsNullOrEmpty($name.DisplayName)) {      
            $line = $name.DisplayName+$separator+$name.DisplayVersion+$separator+$name.InstallDate
            Write-Host $line
            Add-Content $tmpFile "$line`n"
        }
    }
    
    # Sorts the result, removes duplicate lines and
    # generates the final file.
    gc $tmpFile | sort | get-unique > $filename
    
    0 讨论(0)
  • 2020-12-01 02:22

    An application does not need to have any registry entry. In fact, many applications do not need to be installed at all. U3 USB sticks are a good example; the programs on them just run from the file system.

    As noted, most good applications can be found via their uninstall registry key though. This is actually a pair of keys, per-user and per-machine (HKCU/HKLM - Piskvor mentioned only the HKLM one). It does not (always) give you the install directory, though.

    If it's in HKCU, then you have to realise that HKEY_CURRENT_USER really means "Current User". Other users have their own HKCU entries, and their own installed software. You can't find that. Reading every HKEY_USERS hive is a disaster on corporate networks with roaming profiles. You really don't want to fetch 1000 accounts from your remote [US|China|Europe] office.

    Even if an application is installed, and you know where, it may not have the same "version" notion you have. The best source is the "version" resource in the executables. That's indeed a plural, so you have to find all of them, extract version resources from all and in case of a conflict decid on something reasonable.

    So - good luck. There are dozes of ways to fail.

    0 讨论(0)
  • 2020-12-01 02:28

    In addition to all the registry keys mentioned above, you may also have to look at HKEY_CURRENT_USER\Software\Microsoft\Installer\Products for programs installed just for the current user.

    0 讨论(0)
提交回复
热议问题