是否有删除/卸载任何应用程序的通用行



是否有一个通用行可以删除/卸载控制面板中显示的任何应用程序?最好是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

它没有通用的行,Get-Package是一个上帝命令,但如果你想远程使用它,它会变得很难处理,因为它需要调用(使用invoke时有太多问题,只有管理员帐户是不够的,所以它无法实现创建此应用程序的目的(。我正在考虑使用以下组合:

`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包在远程上不可用。而WmiObject没有问题。

我仍然没有找到一种方法来删除.EXE应用程序远程使用管理员帐户。(当然有PowerShell(

我是新手,所以我的术语没有其他人那么发达,但我想我在中明白了我的观点

相关内容

最新更新