获取与添加/删除程序列表匹配的已安装应用程序列表 [英] Getting List of Installed Applications that Matches Add/Remove Programs List

查看:40
本文介绍了获取与添加/删除程序列表匹配的已安装应用程序列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个应用程序,该应用程序列出了客户计算机上所有已安装的程序.我已经能够获得基于注册表项的列表,但它不包括通过 Microsoft Store 安装的内容.它看起来像使用 PowerShell(基于此页面上的指导:https://mhelp.pro/how-to-uninstall-windows-apps/) 我可以获得已安装应用程序的列表,但我得到的似乎包括许多不在添加/删除程序"中的项目,而且我不确定如何协调这两个来源(通过 PowerShell 添加/删除程序和程序列表).是否有更好的方法来执行此操作,或者是否应该使用标志或标准来确定添加/删除程序"中是否存在列出的应用程序?

I'm working on an application that lists all of the installed programs on a customer's computer. I've been able to get a list based on registry keys, but it doesn't include things that were installed via the Microsoft Store. It looks like using PowerShell (based on the guidance on this page: https://mhelp.pro/how-to-uninstall-windows-apps/) I can get lists of installed applications, but what I'm getting there seems to include a lot of items that aren't in Add/Remove Programs, and I'm not sure how to reconcile the 2 sources (Add/Remove Programs and the lists of programs via PowerShell). Is there some better way I should be doing this, or is there a flag or criteria that I should be using to determine if a listed application is present in Add/Remove Programs?

推荐答案

也许你的意思是这样的?

Perhaps something like that did you mean ?

参考 如何在 Windows 上创建已安装程序的列表

$outputFile = "$env:APPDATA\Installed_Applications.txt"
$OS_Architecture = $env:PROCESSOR_ARCHITECTURE
if($OS_Architecture -eq 'x86') 
{
    #write-host '32-bit'
    $key = "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*"
}
else
{
    #write-host '64-bit'
    $key = "HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*"
}

Get-ItemProperty $Key |
        Select-Object DisplayName, DisplayVersion, Publisher, InstallDate |
            Format-Table –AutoSize |
                Out-File $outputFile -Encoding UTF8 -Force
                    Start-Process $outputFile


25/08/2020 @ 18:20

这是一个自我提升脚本,用于获取具有管理员权限的所有内容:

Here is a Self-elevate script to get everything with admin rights :

cls
# Self-elevate the script if required
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
  if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
      #$CommandLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" " + $MyInvocation.UnboundArguments
      $CommandLine = $MyInvocation.InvocationName
      Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine
      Exit
     }
    }

$outputFile = "$env:APPDATA\Installed_Applications.txt"
$OS_Architecture = $env:PROCESSOR_ARCHITECTURE
if($OS_Architecture -eq 'x86') 
{
    #write-host '32-bit'
    $key = "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*"
}
else
{
    #write-host '64-bit'
    $key = "HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*"
}

Get-ItemProperty $Key |
        Select-Object DisplayName, DisplayVersion, Publisher, InstallDate |
            Format-Table –AutoSize | Out-String -Width 300 |
                Out-File $outputFile -Encoding UTF8 -Force 
                    Get-AppxPackage -AllUsers |
                        Out-File -Append $outputFile -Encoding UTF8 -Force 
                            Start $outputFile

这篇关于获取与添加/删除程序列表匹配的已安装应用程序列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆