【问题标题】:is there an universal line to delete/uninstall any application?是否有删除/卸载任何应用程序的通用线路?
【发布时间】:2022-09-27 21:22:38
【问题描述】:

是否有一条通用线路可以删除/卸载控制面板中显示的任何应用程序? 最好是 PowerShell,但可以是另一种语言。 我有删除 .msi 而不是 .EXE 的行。 这部分非常困难,我不了解 .EXE 和 .MSI 之间的区别,如果有人知道如何区分它们,那么我至少可以解决 .msi

这是我为 .msi 设置的代码

$ComputerName = Read-Host -Prompt \'Input the computer name\' # the name of the computer to remove the app from

Get-WmiObject Win32_Product -ComputerName $ComputerName | Select-Object -Property Name | Out-GridView -Title \"All apps on destination Computer\"

$Name = Read-Host -Prompt \'Input name of the application (has to be exact name)\'  #name of the application
$Application = Get-WmiObject Win32_Product -ComputerName $ComputerName | Where-Object {$_.Name -eq $Name}  #choose the object, this will be the app that we will delete
if ($Application) {
  $Application.Uninstall()
  \"
  
  
  
  The removal was successful\"
}
else {
  $Name + \' is not installed on \' + $ComputerName
}
Start-Sleep -Seconds 10

标签: powershell windows-installer exe wmi


【解决方案1】:

没有通用的线路,Get-Package 是一个神命令,但是如果你想远程使用它变得很难处理,因为它需要被调用(调用时问题太多,拥有管理员帐户是不够的,因此它违背了创建此应用程序的目的)。我正在考虑使用以下组合:

`cmd.exe /c "$($app.meta.Attributes["UninstallString"]) /S"`

$Application = Get-WmiObject Win32_Product -ComputerName $ComputerName | Where-Object {$_.Name -eq $Name}  #choose the object, this will be the app that we will delete
if ($Application) {
  $Application.Uninstall()

但随后问题就变成了在适当保护的域中的 Get-package 无法在远程使用。而 WmiObject 没有问题。

我还没有找到使用管理员帐户远程删除 .EXE 应用程序的方法。 (当然使用 PowerShell)

我是新手,所以我的术语不像其他人那样发达,但我想我明白了

【讨论】:

    猜你喜欢
    • 2012-01-21
    • 2015-10-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-02
    • 2012-02-28
    • 2017-04-21
    • 1970-01-01
    相关资源
    最近更新 更多